Merge lp:~cjwatson/storm/py3-misc-functions into lp:storm

Proposed by Colin Watson on 2019-08-11
Status: Merged
Merged at revision: 519
Proposed branch: lp:~cjwatson/storm/py3-misc-functions
Merge into: lp:storm
Diff against target: 120 lines (+10/-12)
6 files modified
tests/cache.py (+3/-3)
tests/database.py (+2/-2)
tests/helper.py (+2/-1)
tests/schema/schema.py (+1/-3)
tests/store/base.py (+1/-2)
tests/tracer.py (+1/-1)
To merge this branch: bzr merge lp:~cjwatson/storm/py3-misc-functions
Reviewer Review Type Date Requested Status
Kristian Glass (community) Approve on 2019-08-12
Storm Developers 2019-08-11 Pending
Review via email: mp+371167@code.launchpad.net

Commit message

Make various small adjustments to cope with changes in Python 3.

Description of the change

These are all small and hopefully uncontroversial, so I decided to just bundle them into a single MP.

To post a comment you must log in.
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/cache.py'
2--- tests/cache.py 2019-06-05 11:41:07 +0000
3+++ tests/cache.py 2019-08-11 12:37:39 +0000
4@@ -136,7 +136,7 @@
5 """
6 size = 10
7 cache = self.Cache(size)
8- for value in xrange(size):
9+ for value in range(size):
10 cache.add(StubObjectInfo(value))
11 self.assertEqual(len(cache.get_cached()), size)
12
13@@ -257,7 +257,7 @@
14 """
15 size = 10
16 cache = GenerationalCache(size)
17- for value in xrange(5 * size):
18+ for value in range(5 * size):
19 cache.add(StubObjectInfo(value))
20 self.assertEquals(len(cache.get_cached()), size * 2)
21
22@@ -300,7 +300,7 @@
23 size = 10
24 cache = GenerationalCache(size * 100)
25 cache.set_size(size)
26- for value in xrange(size * 10):
27+ for value in range(size * 10):
28 cache.add(StubObjectInfo(value))
29 self.assertEquals(len(cache.get_cached()), size * 2)
30
31
32=== modified file 'tests/database.py'
33--- tests/database.py 2019-06-25 21:33:26 +0000
34+++ tests/database.py 2019-08-11 12:37:39 +0000
35@@ -21,7 +21,7 @@
36 from __future__ import print_function
37
38 import sys
39-import new
40+import types
41 import gc
42
43 from storm.exceptions import ClosedError, DatabaseError, DisconnectionError
44@@ -522,7 +522,7 @@
45
46 def setUp(self):
47 TestHelper.setUp(self)
48- self.db_module = new.module("db_module")
49+ self.db_module = types.ModuleType("db_module")
50 self.uri = None
51 def create_from_uri(uri):
52 self.uri = uri
53
54=== modified file 'tests/helper.py'
55--- tests/helper.py 2019-06-05 11:41:07 +0000
56+++ tests/helper.py 2019-08-11 12:37:39 +0000
57@@ -20,12 +20,13 @@
58 #
59 from __future__ import print_function
60
61-from cStringIO import StringIO
62 import tempfile
63 import logging
64 import shutil
65 import sys
66
67+from six.moves import cStringIO as StringIO
68+
69 from tests import mocker
70
71
72
73=== modified file 'tests/schema/schema.py'
74--- tests/schema/schema.py 2019-06-05 11:41:07 +0000
75+++ tests/schema/schema.py 2019-08-11 12:37:39 +0000
76@@ -67,9 +67,7 @@
77 for name in list(sys.modules):
78 if name in self._package_names:
79 del sys.modules[name]
80- elif filter(
81- None,
82- [name.startswith("%s." % x) for x in self._package_names]):
83+ elif any(name.startswith("%s." % x) for x in self._package_names):
84 del sys.modules[name]
85
86 super(SchemaTest, self).tearDown()
87
88=== modified file 'tests/store/base.py'
89--- tests/store/base.py 2019-06-07 17:14:33 +0000
90+++ tests/store/base.py 2019-08-11 12:37:39 +0000
91@@ -22,7 +22,6 @@
92
93 from __future__ import print_function
94
95-from cStringIO import StringIO
96 import decimal
97 import gc
98 import operator
99@@ -30,7 +29,7 @@
100 import weakref
101
102 import six
103-from six.moves import cPickle as pickle
104+from six.moves import cPickle as pickle, cStringIO as StringIO
105
106 from storm.references import Reference, ReferenceSet, Proxy
107 from storm.database import Result, STATE_DISCONNECTED
108
109=== modified file 'tests/tracer.py'
110--- tests/tracer.py 2019-06-05 11:41:07 +0000
111+++ tests/tracer.py 2019-08-11 12:37:39 +0000
112@@ -130,7 +130,7 @@
113
114 def setUp(self):
115 super(DebugTracerTest, self).setUp()
116- self.stream = self.mocker.mock(file)
117+ self.stream = self.mocker.mock(type(sys.stderr))
118 self.tracer = DebugTracer(self.stream)
119
120 datetime_mock = self.mocker.replace("datetime.datetime")

Subscribers

People subscribed via source and target branches

to status/vote changes: