← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/txpkgupload:py3-doctest-fixes into txpkgupload:master

 

Colin Watson has proposed merging ~cjwatson/txpkgupload:py3-doctest-fixes into txpkgupload:master.

Commit message:
Fix various Python 3 issues in doctests

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/txpkgupload/+git/txpkgupload/+merge/392956
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/txpkgupload:py3-doctest-fixes into txpkgupload:master.
diff --git a/src/txpkgupload/tests/filesystem.txt b/src/txpkgupload/tests/filesystem.txt
index e630558..6882b22 100644
--- a/src/txpkgupload/tests/filesystem.txt
+++ b/src/txpkgupload/tests/filesystem.txt
@@ -64,8 +64,8 @@ It recursively creates directories:
     >>> os.path.exists(wanted_path)
     True
 
-    >>> oct(os.stat(wanted_path).st_mode)
-    '040775'
+    >>> print('0o%o' % os.stat(wanted_path).st_mode)
+    0o40775
 
     >>> shutil.rmtree(os.path.join(rootpath, "anything"))
 
@@ -224,6 +224,7 @@ server returns an error to the client and the client does not receive
 bogus or empty data.
 
     >>> ufs.readfile(testfile, None)
+    ... # doctest: +IGNORE_EXCEPTION_DETAIL
     Traceback (most recent call last):
     ...
     Unauthorized
@@ -332,13 +333,17 @@ names
 
 The `names` command returns a sequence of the names in the `path`.
 
-    >>> sorted(ufs.names("."))
-    ['testdir', 'testfile']
+    >>> for name in sorted(ufs.names(".")):
+    ...     print(name)
+    testdir
+    testfile
 
 `path` is normalized before used.
 
-    >>> sorted(ufs.names("some-directory/..")) 
-    ['testdir', 'testfile']
+    >>> for name in sorted(ufs.names("some-directory/..")):
+    ...     print(name)
+    testdir
+    testfile
 
 'path' under the server root is not allowed:
 
@@ -354,8 +359,10 @@ the given `filter` function returns True for it.
     >>> ufs.names(".", always_false_filter)
     []
 
-    >>> sorted(ufs.names(".", always_true_filter))
-    ['testdir', 'testfile']
+    >>> for name in sorted(ufs.names(".", always_true_filter)):
+    ...     print(name)
+    testdir
+    testfile
 
     >>> for i in [ "foo", "bar", "baz", "bat" ]:
     ...     x = open(os.path.join(rootpath, i), 'w')
diff --git a/src/txpkgupload/tests/test_filesystem.py b/src/txpkgupload/tests/test_filesystem.py
index a658e73..bb77a9f 100644
--- a/src/txpkgupload/tests/test_filesystem.py
+++ b/src/txpkgupload/tests/test_filesystem.py
@@ -1,6 +1,8 @@
 # Copyright 2009 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+from __future__ import absolute_import, print_function, unicode_literals
+
 __metaclass__ = type
 
 import doctest
@@ -23,7 +25,13 @@ def tearDown(testobj):
     os.umask(testobj._old_umask)
 
 
-def additional_tests():
-    return doctest.DocFileSuite(
-        "filesystem.txt", setUp=setUp, tearDown=tearDown,
-        optionflags=DOCTEST_FLAGS)
+def load_tests(loader, tests, pattern):
+    globs = {
+        "absolute_import": absolute_import,
+        "print_function": print_function,
+        "unicode_literals": unicode_literals,
+        }
+    tests.addTest(doctest.DocFileSuite(
+        "filesystem.txt", setUp=setUp, tearDown=tearDown, globs=globs,
+        optionflags=DOCTEST_FLAGS))
+    return tests