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

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 95007956a4b157d9f3675666cae60571f7a29bd5
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/txpkgupload:py3-doctest-fixes
Merge into: txpkgupload:master
Diff against target: 89 lines (+27/-12)
2 files modified
src/txpkgupload/tests/filesystem.txt (+15/-8)
src/txpkgupload/tests/test_filesystem.py (+12/-4)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+392956@code.launchpad.net

Commit message

Fix various Python 3 issues in doctests

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/txpkgupload/tests/filesystem.txt b/src/txpkgupload/tests/filesystem.txt
2index e630558..6882b22 100644
3--- a/src/txpkgupload/tests/filesystem.txt
4+++ b/src/txpkgupload/tests/filesystem.txt
5@@ -64,8 +64,8 @@ It recursively creates directories:
6 >>> os.path.exists(wanted_path)
7 True
8
9- >>> oct(os.stat(wanted_path).st_mode)
10- '040775'
11+ >>> print('0o%o' % os.stat(wanted_path).st_mode)
12+ 0o40775
13
14 >>> shutil.rmtree(os.path.join(rootpath, "anything"))
15
16@@ -224,6 +224,7 @@ server returns an error to the client and the client does not receive
17 bogus or empty data.
18
19 >>> ufs.readfile(testfile, None)
20+ ... # doctest: +IGNORE_EXCEPTION_DETAIL
21 Traceback (most recent call last):
22 ...
23 Unauthorized
24@@ -332,13 +333,17 @@ names
25
26 The `names` command returns a sequence of the names in the `path`.
27
28- >>> sorted(ufs.names("."))
29- ['testdir', 'testfile']
30+ >>> for name in sorted(ufs.names(".")):
31+ ... print(name)
32+ testdir
33+ testfile
34
35 `path` is normalized before used.
36
37- >>> sorted(ufs.names("some-directory/.."))
38- ['testdir', 'testfile']
39+ >>> for name in sorted(ufs.names("some-directory/..")):
40+ ... print(name)
41+ testdir
42+ testfile
43
44 'path' under the server root is not allowed:
45
46@@ -354,8 +359,10 @@ the given `filter` function returns True for it.
47 >>> ufs.names(".", always_false_filter)
48 []
49
50- >>> sorted(ufs.names(".", always_true_filter))
51- ['testdir', 'testfile']
52+ >>> for name in sorted(ufs.names(".", always_true_filter)):
53+ ... print(name)
54+ testdir
55+ testfile
56
57 >>> for i in [ "foo", "bar", "baz", "bat" ]:
58 ... x = open(os.path.join(rootpath, i), 'w')
59diff --git a/src/txpkgupload/tests/test_filesystem.py b/src/txpkgupload/tests/test_filesystem.py
60index a658e73..bb77a9f 100644
61--- a/src/txpkgupload/tests/test_filesystem.py
62+++ b/src/txpkgupload/tests/test_filesystem.py
63@@ -1,6 +1,8 @@
64 # Copyright 2009 Canonical Ltd. This software is licensed under the
65 # GNU Affero General Public License version 3 (see the file LICENSE).
66
67+from __future__ import absolute_import, print_function, unicode_literals
68+
69 __metaclass__ = type
70
71 import doctest
72@@ -23,7 +25,13 @@ def tearDown(testobj):
73 os.umask(testobj._old_umask)
74
75
76-def additional_tests():
77- return doctest.DocFileSuite(
78- "filesystem.txt", setUp=setUp, tearDown=tearDown,
79- optionflags=DOCTEST_FLAGS)
80+def load_tests(loader, tests, pattern):
81+ globs = {
82+ "absolute_import": absolute_import,
83+ "print_function": print_function,
84+ "unicode_literals": unicode_literals,
85+ }
86+ tests.addTest(doctest.DocFileSuite(
87+ "filesystem.txt", setUp=setUp, tearDown=tearDown, globs=globs,
88+ optionflags=DOCTEST_FLAGS))
89+ return tests

Subscribers

People subscribed via source and target branches

to all changes: