← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/txpkgupload:py3-writeChunk-bytes into txpkgupload:master

 

Colin Watson has proposed merging ~cjwatson/txpkgupload:py3-writeChunk-bytes into txpkgupload:master.

Commit message:
Explicitly pass bytes to writeChunk in tests

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/txpkgupload/+git/txpkgupload/+merge/392888
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/txpkgupload:py3-writeChunk-bytes into txpkgupload:master.
diff --git a/src/txpkgupload/tests/test_plugin.py b/src/txpkgupload/tests/test_plugin.py
index 7d8450d..29418af 100644
--- a/src/txpkgupload/tests/test_plugin.py
+++ b/src/txpkgupload/tests/test_plugin.py
@@ -534,7 +534,7 @@ class TestPkgUploadServiceMakerMixin:
         The uploaded file permissions are also special (g+rwxs).
         """
         client = yield self.server.getClient()
-        yield self.server.createFile(client, "foo/bar/baz", "fake contents")
+        yield self.server.createFile(client, "foo/bar/baz", b"fake contents")
 
         yield self.server.disconnect(client)
         yield self.server.waitForClose()
@@ -563,7 +563,8 @@ class TestPkgUploadServiceMakerMixin:
         for upload in files:
             fake_file = StringIO.StringIO(upload)
             file_to_upload = "~ppa-user/ppa/ubuntu/%s" % upload
-            yield self.server.createFile(client, file_to_upload, upload)
+            yield self.server.createFile(
+                client, file_to_upload, upload.encode("ASCII"))
 
         yield self.server.disconnect(client)
         yield self.server.waitForClose()
@@ -598,12 +599,12 @@ class TestPkgUploadServiceMakerMixin:
         """
         # Perform a pair of sessions with distinct connections in time.
         conn_one = yield self.server.getClient()
-        yield self.server.createFile(conn_one, "test", "ONE")
+        yield self.server.createFile(conn_one, "test", b"ONE")
         yield self.server.disconnect(conn_one)
         yield self.server.waitForClose(1)
 
         conn_two = yield self.server.getClient()
-        yield self.server.createFile(conn_two, "test", "TWO")
+        yield self.server.createFile(conn_two, "test", b"TWO")
         yield self.server.disconnect(conn_two)
         yield self.server.waitForClose(2)
 
@@ -611,9 +612,9 @@ class TestPkgUploadServiceMakerMixin:
         conn_three = yield self.server.getClient()
         conn_four = yield self.server.getClient()
 
-        yield self.server.createFile(conn_three, "test", "THREE")
+        yield self.server.createFile(conn_three, "test", b"THREE")
 
-        yield self.server.createFile(conn_four, "test", "FOUR")
+        yield self.server.createFile(conn_four, "test", b"FOUR")
 
         yield self.server.disconnect(conn_three)
         yield self.server.waitForClose(3)
@@ -682,7 +683,7 @@ class TestPkgUploadServiceMakerSFTP(TestPkgUploadServiceMakerMixin, TestCase):
     def test_stat(self):
         """Check that attribute retrieval doesn't give anything away."""
         client = yield self.server.getClient()
-        yield self.server.createFile(client, "foo/bar/baz", "fake contents")
+        yield self.server.createFile(client, "foo/bar/baz", b"fake contents")
         attrs = yield client.getAttrs("foo/bar/baz")
         self.assertEqual({}, attrs)
 
@@ -693,7 +694,7 @@ class TestPkgUploadServiceMakerSFTP(TestPkgUploadServiceMakerMixin, TestCase):
     def test_fstat(self):
         """Check that file attribute retrieval doesn't give anything away."""
         client = yield self.server.getClient()
-        yield self.server.createFile(client, "foo/bar/baz", "fake contents")
+        yield self.server.createFile(client, "foo/bar/baz", b"fake contents")
         remote_file = yield client.openFile("foo/bar/baz", FXF_READ, {})
         attrs = yield remote_file.getAttrs()
         self.assertEqual({}, attrs)
@@ -706,7 +707,7 @@ class TestPkgUploadServiceMakerSFTP(TestPkgUploadServiceMakerMixin, TestCase):
     def test_openDirectory(self):
         """Check that opening a directory doesn't give anything away."""
         client = yield self.server.getClient()
-        yield self.server.createFile(client, "foo/bar/baz", "fake contents")
+        yield self.server.createFile(client, "foo/bar/baz", b"fake contents")
         directory = yield client.openDirectory(".")
         try:
             entry = yield next(directory)
diff --git a/src/txpkgupload/tests/test_twistedsftp.py b/src/txpkgupload/tests/test_twistedsftp.py
index bf002ca..3ddeeb0 100644
--- a/src/txpkgupload/tests/test_twistedsftp.py
+++ b/src/txpkgupload/tests/test_twistedsftp.py
@@ -62,7 +62,7 @@ class TestSFTPServer(testtools.TestCase):
 
     def test_file_creation(self):
         upload_file = self.sftp_server.openFile('foo/bar', None, None)
-        upload_file.writeChunk(0, "This is a test")
+        upload_file.writeChunk(0, b"This is a test")
         file_name = os.path.join(self.sftp_server._current_upload, 'foo/bar')
         test_file = open(file_name, 'r')
         self.assertEqual(test_file.read(), "This is a test")
@@ -72,5 +72,5 @@ class TestSFTPServer(testtools.TestCase):
         os.makedirs(dir_name)
         upload_file = self.sftp_server.openFile('bar/foo', None, None)
         err = self.assertRaises(
-            FileIsADirectory, upload_file.writeChunk, 0, "This is a test")
+            FileIsADirectory, upload_file.writeChunk, 0, b"This is a test")
         self.assertEqual("File is a directory: '%s'" % dir_name, str(err))