Merge lp:~cjwatson/storm/py3-fix-schema-patch-tests into lp:storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 524
Proposed branch: lp:~cjwatson/storm/py3-fix-schema-patch-tests
Merge into: lp:storm
Diff against target: 41 lines (+12/-4)
1 file modified
tests/schema/patch.py (+12/-4)
To merge this branch: bzr merge lp:~cjwatson/storm/py3-fix-schema-patch-tests
Reviewer Review Type Date Requested Status
Simon Poirier (community) Approve
Review via email: mp+371175@code.launchpad.net

Commit message

Fix Python 3 compatibility problems in tests.schema.patch.

To post a comment you must log in.
Revision history for this message
Simon Poirier (simpoir) wrote :

+1 LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/schema/patch.py'
2--- tests/schema/patch.py 2019-06-05 11:41:07 +0000
3+++ tests/schema/patch.py 2019-08-11 17:35:36 +0000
4@@ -20,9 +20,10 @@
5 #
6 from __future__ import print_function
7
8+import os
9+import shutil
10+import sys
11 import traceback
12-import sys
13-import os
14
15 from storm.locals import StormError, Store, create_database
16 from storm.schema.patch import (
17@@ -174,7 +175,11 @@
18
19 def remove_all_modules(self):
20 for filename in os.listdir(self.pkgdir):
21- os.unlink(os.path.join(self.pkgdir, filename))
22+ path = os.path.join(self.pkgdir, filename)
23+ if os.path.isdir(path):
24+ shutil.rmtree(path)
25+ else:
26+ os.unlink(path)
27
28 def prepare_for_transaction_check(self):
29 self.another_store.execute("DELETE FROM test")
30@@ -349,7 +354,10 @@
31 self.patch_applier.apply_all()
32 except BadPatchError as e:
33 self.assertTrue("mypackage/patch_999.py" in str(e))
34- self.assertTrue("takes no arguments" in str(e))
35+ if sys.version_info >= (3, 3):
36+ self.assertTrue("takes 0 positional arguments" in str(e))
37+ else:
38+ self.assertTrue("takes no arguments" in str(e))
39 self.assertTrue("TypeError" in str(e))
40 else:
41 self.fail("BadPatchError not raised")

Subscribers

People subscribed via source and target branches

to status/vote changes: