Merge ~pappacena/turnip:py3-functional-tests-initialization into turnip:master

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Thiago F. Pappacena
Approved revision: d46d89c705e58ab87b61de34e9ab3013909e8364
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/turnip:py3-functional-tests-initialization
Merge into: turnip:master
Diff against target: 81 lines (+14/-10)
2 files modified
turnip/pack/tests/fake_servers.py (+3/-2)
turnip/pack/tests/test_functional.py (+11/-8)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+393780@code.launchpad.net

Commit message

Fixing some functional tests initialization py3 compatibilities

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
7f7d4f9... by Thiago F. Pappacena

Merge branch 'master' into py3-functional-tests-initialization

d46d89c... by Thiago F. Pappacena

Fixing incompatibility with py2 and non-binary file paths

Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

Thanks for the comments.

All should be fixed now. Now TestSmartSSHServiceFunctional and some other smaller functional tests run on both py2 and py3! :-)

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/turnip/pack/tests/fake_servers.py b/turnip/pack/tests/fake_servers.py
2index 9130614..7087da9 100644
3--- a/turnip/pack/tests/fake_servers.py
4+++ b/turnip/pack/tests/fake_servers.py
5@@ -82,9 +82,10 @@ class FakeVirtInfoService(xmlrpc.XMLRPC):
6 self.abort_repo_creation_call_args = []
7
8 def getInternalPath(self, pathname):
9- if pathname.startswith('/+rw'):
10+ pathname = six.ensure_binary(pathname)
11+ if pathname.startswith(b'/+rw'):
12 pathname = pathname[4:]
13- return hashlib.sha256(six.ensure_binary(pathname)).hexdigest()
14+ return hashlib.sha256(pathname).hexdigest()
15
16 def xmlrpc_translatePath(self, pathname, permission, auth_params):
17 if self.require_auth and 'user' not in auth_params:
18diff --git a/turnip/pack/tests/test_functional.py b/turnip/pack/tests/test_functional.py
19index 97a99d2..c044968 100644
20--- a/turnip/pack/tests/test_functional.py
21+++ b/turnip/pack/tests/test_functional.py
22@@ -188,7 +188,7 @@ class FunctionalTestMixin(WithScenarios):
23
24 def assertStatsdSuccess(self, repo, command):
25 metrics = ['max_rss', 'system_time', 'user_time']
26- repository = re.sub('[^0-9a-zA-Z]+', '-', repo)
27+ repository = re.sub('[^0-9a-zA-Z]+', '-', six.ensure_str(repo))
28 self.assertThat(self.statsd_client.vals, MatchesDict({
29 u'git,operation={},repo={},env={},metric={}'
30 .format(
31@@ -934,9 +934,10 @@ class TestSmartSSHServiceFunctional(FrontendFunctionalTestMixin, TestCase):
32 def setUp(self):
33 yield super(TestSmartSSHServiceFunctional, self).setUp()
34
35- config = os.path.join(self.root, "ssh-config")
36- known_hosts = os.path.join(self.root, "known_hosts")
37- private_key = os.path.join(self.root, "ssh-key")
38+ root = six.ensure_text(self.root)
39+ config = os.path.join(root, "ssh-config")
40+ known_hosts = os.path.join(root, "known_hosts")
41+ private_key = os.path.join(root, "ssh-key")
42 shutil.copy2(os.path.join(self.data_dir, "ssh-key"), private_key)
43 os.chmod(private_key, stat.S_IRUSR | stat.S_IWUSR)
44 public_key = os.path.join(self.data_dir, "ssh-key.pub")
45@@ -946,7 +947,7 @@ class TestSmartSSHServiceFunctional(FrontendFunctionalTestMixin, TestCase):
46 print("StrictHostKeyChecking no", file=config_file)
47 print("User example", file=config_file)
48 print("UserKnownHostsFile %s" % known_hosts, file=config_file)
49- git_ssh = os.path.join(self.root, "ssh-wrapper")
50+ git_ssh = os.path.join(root, "ssh-wrapper")
51 with open(git_ssh, "w") as git_ssh_file:
52 print('#! /bin/sh', file=git_ssh_file)
53 print('ssh -F %s "$@"' % config, file=git_ssh_file)
54@@ -955,22 +956,24 @@ class TestSmartSSHServiceFunctional(FrontendFunctionalTestMixin, TestCase):
55 stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
56 os.chmod(git_ssh, new_mode)
57 self.useFixture(EnvironmentVariable("GIT_SSH", git_ssh))
58+ self.useFixture(EnvironmentVariable("GIT_SSH_VARIANT", "ssh"))
59
60 self.authserver.addSSHKey("example", public_key)
61
62 # We run a service connecting to the backend and authserver servers
63 # started by the mixin.
64- private_host_key = os.path.join(self.root, "ssh-host-key")
65+ private_host_key = os.path.join(root, "ssh-host-key")
66 shutil.copy2(
67 os.path.join(self.data_dir, "ssh-host-key"), private_host_key)
68 os.chmod(private_host_key, stat.S_IRUSR | stat.S_IWUSR)
69 public_host_key = os.path.join(self.data_dir, "ssh-host-key.pub")
70+
71 self.service = SmartSSHService(
72 b'localhost', self.virt_port, self.authserver_url,
73 private_key_path=private_host_key, public_key_path=public_host_key,
74 main_log="turnip", access_log="turnip.access",
75- access_log_path=os.path.join(self.root, "access.log"),
76- strport=b'tcp:0', moduli_path="/etc/ssh/moduli")
77+ access_log_path=os.path.join(root, "access.log"),
78+ strport=six.ensure_str('tcp:0'), moduli_path="/etc/ssh/moduli")
79 self.service.startService()
80 self.addCleanup(self.service.stopService)
81 socket = self.service.service._waitingForPort.result.socket

Subscribers

People subscribed via source and target branches