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
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:
64 >>> os.path.exists(wanted_path)64 >>> os.path.exists(wanted_path)
65 True65 True
6666
67 >>> oct(os.stat(wanted_path).st_mode)67 >>> print('0o%o' % os.stat(wanted_path).st_mode)
68 '040775'68 0o40775
6969
70 >>> shutil.rmtree(os.path.join(rootpath, "anything"))70 >>> shutil.rmtree(os.path.join(rootpath, "anything"))
7171
@@ -224,6 +224,7 @@ server returns an error to the client and the client does not receive
224bogus or empty data.224bogus or empty data.
225225
226 >>> ufs.readfile(testfile, None)226 >>> ufs.readfile(testfile, None)
227 ... # doctest: +IGNORE_EXCEPTION_DETAIL
227 Traceback (most recent call last):228 Traceback (most recent call last):
228 ...229 ...
229 Unauthorized230 Unauthorized
@@ -332,13 +333,17 @@ names
332333
333The `names` command returns a sequence of the names in the `path`.334The `names` command returns a sequence of the names in the `path`.
334335
335 >>> sorted(ufs.names("."))336 >>> for name in sorted(ufs.names(".")):
336 ['testdir', 'testfile']337 ... print(name)
338 testdir
339 testfile
337340
338`path` is normalized before used.341`path` is normalized before used.
339342
340 >>> sorted(ufs.names("some-directory/..")) 343 >>> for name in sorted(ufs.names("some-directory/..")):
341 ['testdir', 'testfile']344 ... print(name)
345 testdir
346 testfile
342347
343'path' under the server root is not allowed:348'path' under the server root is not allowed:
344349
@@ -354,8 +359,10 @@ the given `filter` function returns True for it.
354 >>> ufs.names(".", always_false_filter)359 >>> ufs.names(".", always_false_filter)
355 []360 []
356361
357 >>> sorted(ufs.names(".", always_true_filter))362 >>> for name in sorted(ufs.names(".", always_true_filter)):
358 ['testdir', 'testfile']363 ... print(name)
364 testdir
365 testfile
359366
360 >>> for i in [ "foo", "bar", "baz", "bat" ]:367 >>> for i in [ "foo", "bar", "baz", "bat" ]:
361 ... x = open(os.path.join(rootpath, i), 'w')368 ... 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 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4from __future__ import absolute_import, print_function, unicode_literals
5
4__metaclass__ = type6__metaclass__ = type
57
6import doctest8import doctest
@@ -23,7 +25,13 @@ def tearDown(testobj):
23 os.umask(testobj._old_umask)25 os.umask(testobj._old_umask)
2426
2527
26def additional_tests():28def load_tests(loader, tests, pattern):
27 return doctest.DocFileSuite(29 globs = {
28 "filesystem.txt", setUp=setUp, tearDown=tearDown,30 "absolute_import": absolute_import,
29 optionflags=DOCTEST_FLAGS)31 "print_function": print_function,
32 "unicode_literals": unicode_literals,
33 }
34 tests.addTest(doctest.DocFileSuite(
35 "filesystem.txt", setUp=setUp, tearDown=tearDown, globs=globs,
36 optionflags=DOCTEST_FLAGS))
37 return tests

Subscribers

People subscribed via source and target branches

to all changes: