Merge lp:~cjwatson/storm/pyupgrade into lp:storm
- pyupgrade
- Merge into trunk
Proposed by
Colin Watson
Status: | Needs review |
---|---|
Proposed branch: | lp:~cjwatson/storm/pyupgrade |
Merge into: | lp:storm |
Diff against target: |
4619 lines (+583/-597) 56 files modified
storm/__init__.py (+1/-1) storm/cache.py (+2/-2) storm/database.py (+8/-9) storm/databases/__init__.py (+1/-1) storm/databases/mysql.py (+1/-1) storm/databases/postgres.py (+3/-4) storm/databases/sqlite.py (+1/-1) storm/docs/conf.py (+0/-2) storm/event.py (+1/-1) storm/expr.py (+15/-15) storm/info.py (+4/-6) storm/properties.py (+3/-3) storm/references.py (+7/-7) storm/schema/patch.py (+4/-4) storm/schema/schema.py (+2/-2) storm/schema/sharding.py (+1/-1) storm/sqlobject.py (+13/-13) storm/store.py (+7/-7) storm/testing.py (+1/-1) storm/tests/cache.py (+4/-4) storm/tests/database.py (+5/-5) storm/tests/databases/base.py (+17/-19) storm/tests/databases/mysql.py (+2/-2) storm/tests/databases/postgres.py (+31/-32) storm/tests/databases/proxy.py (+1/-2) storm/tests/databases/sqlite.py (+6/-6) storm/tests/event.py (+1/-1) storm/tests/expr.py (+27/-27) storm/tests/helper.py (+5/-5) storm/tests/info.py (+15/-15) storm/tests/mocker.py (+18/-19) storm/tests/properties.py (+13/-13) storm/tests/schema/patch.py (+7/-7) storm/tests/schema/schema.py (+6/-6) storm/tests/schema/sharding.py (+3/-3) storm/tests/sqlobject.py (+15/-15) storm/tests/store/base.py (+266/-267) storm/tests/store/block.py (+1/-1) storm/tests/store/postgres.py (+4/-4) storm/tests/tracer.py (+18/-18) storm/tests/variables.py (+8/-8) storm/tests/wsgi.py (+1/-1) storm/tests/zope/adapters.py (+1/-1) storm/tests/zope/testing.py (+7/-7) storm/tests/zope/zstorm.py (+1/-2) storm/tracer.py (+4/-4) storm/twisted/testing.py (+2/-2) storm/twisted/transact.py (+2/-2) storm/tz.py (+3/-3) storm/uri.py (+1/-1) storm/variables.py (+5/-5) storm/xid.py (+1/-1) storm/zope/metadirectives.py (+2/-2) storm/zope/schema.py (+2/-3) storm/zope/testing.py (+1/-1) storm/zope/zstorm.py (+2/-2) |
To merge this branch: | bzr merge lp:~cjwatson/storm/pyupgrade |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Storm Developers | Pending | ||
Review via email: mp+462336@code.launchpad.net |
Commit message
Run pyupgrade.
Description of the change
Generated using `find storm -name \*.py | xargs pyupgrade --py3-plus --keep-
To post a comment you must log in.
Unmerged revisions
- 585. By Colin Watson
-
Run pyupgrade.
Generated using `find storm -name \*.py | xargs pyupgrade --py3-plus
--keep-percent- format` .
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'storm/__init__.py' | |||
2 | --- storm/__init__.py 2024-03-04 10:59:55 +0000 | |||
3 | +++ storm/__init__.py 2024-03-13 16:26:38 +0000 | |||
4 | @@ -32,7 +32,7 @@ | |||
5 | 32 | version_info = tuple([int(x) for x in version.split(".")]) | 32 | version_info = tuple([int(x) for x in version.split(".")]) |
6 | 33 | 33 | ||
7 | 34 | 34 | ||
9 | 35 | class UndefType(object): | 35 | class UndefType: |
10 | 36 | 36 | ||
11 | 37 | def __repr__(self): | 37 | def __repr__(self): |
12 | 38 | return "Undef" | 38 | return "Undef" |
13 | 39 | 39 | ||
14 | === modified file 'storm/cache.py' | |||
15 | --- storm/cache.py 2024-03-04 10:59:55 +0000 | |||
16 | +++ storm/cache.py 2024-03-13 16:26:38 +0000 | |||
17 | @@ -1,7 +1,7 @@ | |||
18 | 1 | import itertools | 1 | import itertools |
19 | 2 | 2 | ||
20 | 3 | 3 | ||
22 | 4 | class Cache(object): | 4 | class Cache: |
23 | 5 | """Prevents recently used objects from being deallocated. | 5 | """Prevents recently used objects from being deallocated. |
24 | 6 | 6 | ||
25 | 7 | This prevents recently used objects from being deallocated by Python | 7 | This prevents recently used objects from being deallocated by Python |
26 | @@ -69,7 +69,7 @@ | |||
27 | 69 | return list(self._order) | 69 | return list(self._order) |
28 | 70 | 70 | ||
29 | 71 | 71 | ||
31 | 72 | class GenerationalCache(object): | 72 | class GenerationalCache: |
32 | 73 | """Generational replacement for Storm's LRU cache. | 73 | """Generational replacement for Storm's LRU cache. |
33 | 74 | 74 | ||
34 | 75 | This cache approximates LRU without keeping exact track. Instead, | 75 | This cache approximates LRU without keeping exact track. Instead, |
35 | 76 | 76 | ||
36 | === modified file 'storm/database.py' | |||
37 | --- storm/database.py 2024-03-04 10:59:55 +0000 | |||
38 | +++ storm/database.py 2024-03-13 16:26:38 +0000 | |||
39 | @@ -49,7 +49,7 @@ | |||
40 | 49 | STATE_RECONNECT = 3 | 49 | STATE_RECONNECT = 3 |
41 | 50 | 50 | ||
42 | 51 | 51 | ||
44 | 52 | class Result(object): | 52 | class Result: |
45 | 53 | """A representation of the results from a single SQL statement.""" | 53 | """A representation of the results from a single SQL statement.""" |
46 | 54 | 54 | ||
47 | 55 | _closed = False | 55 | _closed = False |
48 | @@ -164,12 +164,12 @@ | |||
49 | 164 | return row | 164 | return row |
50 | 165 | 165 | ||
51 | 166 | 166 | ||
53 | 167 | class CursorWrapper(object): | 167 | class CursorWrapper: |
54 | 168 | """A DB-API cursor, wrapping exceptions as StormError instances.""" | 168 | """A DB-API cursor, wrapping exceptions as StormError instances.""" |
55 | 169 | 169 | ||
56 | 170 | def __init__(self, cursor, database): | 170 | def __init__(self, cursor, database): |
59 | 171 | super(CursorWrapper, self).__setattr__('_cursor', cursor) | 171 | super().__setattr__('_cursor', cursor) |
60 | 172 | super(CursorWrapper, self).__setattr__('_database', database) | 172 | super().__setattr__('_database', database) |
61 | 173 | 173 | ||
62 | 174 | def __getattr__(self, name): | 174 | def __getattr__(self, name): |
63 | 175 | attr = getattr(self._cursor, name) | 175 | attr = getattr(self._cursor, name) |
64 | @@ -188,8 +188,7 @@ | |||
65 | 188 | 188 | ||
66 | 189 | def __iter__(self): | 189 | def __iter__(self): |
67 | 190 | with wrap_exceptions(self._database): | 190 | with wrap_exceptions(self._database): |
70 | 191 | for item in self._cursor: | 191 | yield from self._cursor |
69 | 192 | yield item | ||
71 | 193 | 192 | ||
72 | 194 | def __enter__(self): | 193 | def __enter__(self): |
73 | 195 | return self | 194 | return self |
74 | @@ -199,7 +198,7 @@ | |||
75 | 199 | self.close() | 198 | self.close() |
76 | 200 | 199 | ||
77 | 201 | 200 | ||
79 | 202 | class ConnectionWrapper(object): | 201 | class ConnectionWrapper: |
80 | 203 | """A DB-API connection, wrapping exceptions as StormError instances.""" | 202 | """A DB-API connection, wrapping exceptions as StormError instances.""" |
81 | 204 | 203 | ||
82 | 205 | def __init__(self, connection, database): | 204 | def __init__(self, connection, database): |
83 | @@ -236,7 +235,7 @@ | |||
84 | 236 | return CursorWrapper(self._connection.cursor(), self._database) | 235 | return CursorWrapper(self._connection.cursor(), self._database) |
85 | 237 | 236 | ||
86 | 238 | 237 | ||
88 | 239 | class Connection(object): | 238 | class Connection: |
89 | 240 | """A connection to a database. | 239 | """A connection to a database. |
90 | 241 | 240 | ||
91 | 242 | @cvar result_factory: A callable which takes this L{Connection} | 241 | @cvar result_factory: A callable which takes this L{Connection} |
92 | @@ -544,7 +543,7 @@ | |||
93 | 544 | """ | 543 | """ |
94 | 545 | 544 | ||
95 | 546 | 545 | ||
97 | 547 | class Database(object): | 546 | class Database: |
98 | 548 | """A database that can be connected to. | 547 | """A database that can be connected to. |
99 | 549 | 548 | ||
100 | 550 | This should be subclassed for individual database backends. | 549 | This should be subclassed for individual database backends. |
101 | 551 | 550 | ||
102 | === modified file 'storm/databases/__init__.py' | |||
103 | --- storm/databases/__init__.py 2024-03-04 10:59:55 +0000 | |||
104 | +++ storm/databases/__init__.py 2024-03-13 16:26:38 +0000 | |||
105 | @@ -20,7 +20,7 @@ | |||
106 | 20 | # | 20 | # |
107 | 21 | 21 | ||
108 | 22 | 22 | ||
110 | 23 | class Dummy(object): | 23 | class Dummy: |
111 | 24 | """Magic "infectious" class. | 24 | """Magic "infectious" class. |
112 | 25 | 25 | ||
113 | 26 | This class simplifies nice errors on the creation of | 26 | This class simplifies nice errors on the creation of |
114 | 27 | 27 | ||
115 | === modified file 'storm/databases/mysql.py' | |||
116 | --- storm/databases/mysql.py 2024-03-04 10:59:55 +0000 | |||
117 | +++ storm/databases/mysql.py 2024-03-13 16:26:38 +0000 | |||
118 | @@ -139,7 +139,7 @@ | |||
119 | 139 | _converters = None | 139 | _converters = None |
120 | 140 | 140 | ||
121 | 141 | def __init__(self, uri): | 141 | def __init__(self, uri): |
123 | 142 | super(MySQL, self).__init__(uri) | 142 | super().__init__(uri) |
124 | 143 | if MySQLdb is dummy: | 143 | if MySQLdb is dummy: |
125 | 144 | raise DatabaseModuleError("'MySQLdb' module not found") | 144 | raise DatabaseModuleError("'MySQLdb' module not found") |
126 | 145 | self._connect_kwargs = {} | 145 | self._connect_kwargs = {} |
127 | 146 | 146 | ||
128 | === modified file 'storm/databases/postgres.py' | |||
129 | --- storm/databases/postgres.py 2024-03-04 16:33:02 +0000 | |||
130 | +++ storm/databases/postgres.py 2024-03-13 16:26:38 +0000 | |||
131 | @@ -369,7 +369,7 @@ | |||
132 | 369 | _version = None | 369 | _version = None |
133 | 370 | 370 | ||
134 | 371 | def __init__(self, uri): | 371 | def __init__(self, uri): |
136 | 372 | super(Postgres, self).__init__(uri) | 372 | super().__init__(uri) |
137 | 373 | if psycopg2 is dummy: | 373 | if psycopg2 is dummy: |
138 | 374 | raise DatabaseModuleError( | 374 | raise DatabaseModuleError( |
139 | 375 | "'psycopg2' >= %s not found. Found %s." | 375 | "'psycopg2' >= %s not found. Found %s." |
140 | @@ -400,15 +400,14 @@ | |||
141 | 400 | _psycopg_error_attributes = tuple(_psycopg_error_attributes) | 400 | _psycopg_error_attributes = tuple(_psycopg_error_attributes) |
142 | 401 | 401 | ||
143 | 402 | def _make_combined_exception_type(self, wrapper_type, dbapi_type): | 402 | def _make_combined_exception_type(self, wrapper_type, dbapi_type): |
145 | 403 | combined_type = super(Postgres, self)._make_combined_exception_type( | 403 | combined_type = super()._make_combined_exception_type( |
146 | 404 | wrapper_type, dbapi_type) | 404 | wrapper_type, dbapi_type) |
147 | 405 | for name in self._psycopg_error_attributes: | 405 | for name in self._psycopg_error_attributes: |
148 | 406 | setattr(combined_type, name, lambda err: getattr(err, "_" + name)) | 406 | setattr(combined_type, name, lambda err: getattr(err, "_" + name)) |
149 | 407 | return combined_type | 407 | return combined_type |
150 | 408 | 408 | ||
151 | 409 | def _wrap_exception(self, wrapper_type, exception): | 409 | def _wrap_exception(self, wrapper_type, exception): |
154 | 410 | wrapped = super(Postgres, self)._wrap_exception( | 410 | wrapped = super()._wrap_exception(wrapper_type, exception) |
153 | 411 | wrapper_type, exception) | ||
155 | 412 | for name in self._psycopg_error_attributes: | 411 | for name in self._psycopg_error_attributes: |
156 | 413 | setattr(wrapped, "_" + name, getattr(exception, name)) | 412 | setattr(wrapped, "_" + name, getattr(exception, name)) |
157 | 414 | return wrapped | 413 | return wrapped |
158 | 415 | 414 | ||
159 | === modified file 'storm/databases/sqlite.py' | |||
160 | --- storm/databases/sqlite.py 2024-03-04 10:59:55 +0000 | |||
161 | +++ storm/databases/sqlite.py 2024-03-13 16:26:38 +0000 | |||
162 | @@ -163,7 +163,7 @@ | |||
163 | 163 | _exception_module = sqlite | 163 | _exception_module = sqlite |
164 | 164 | 164 | ||
165 | 165 | def __init__(self, uri): | 165 | def __init__(self, uri): |
167 | 166 | super(SQLite, self).__init__(uri) | 166 | super().__init__(uri) |
168 | 167 | if sqlite is dummy: | 167 | if sqlite is dummy: |
169 | 168 | raise DatabaseModuleError("'pysqlite2' module not found") | 168 | raise DatabaseModuleError("'pysqlite2' module not found") |
170 | 169 | self._filename = uri.database or ":memory:" | 169 | self._filename = uri.database or ":memory:" |
171 | 170 | 170 | ||
172 | === modified file 'storm/docs/conf.py' | |||
173 | --- storm/docs/conf.py 2020-05-26 10:28:24 +0000 | |||
174 | +++ storm/docs/conf.py 2024-03-13 16:26:38 +0000 | |||
175 | @@ -1,5 +1,3 @@ | |||
176 | 1 | # -*- coding: utf-8 -*- | ||
177 | 2 | # | ||
178 | 3 | # Configuration file for the Sphinx documentation builder. | 1 | # Configuration file for the Sphinx documentation builder. |
179 | 4 | # | 2 | # |
180 | 5 | # This file does only contain a selection of the most common options. For a | 3 | # This file does only contain a selection of the most common options. For a |
181 | 6 | 4 | ||
182 | === modified file 'storm/event.py' | |||
183 | --- storm/event.py 2024-03-04 10:59:55 +0000 | |||
184 | +++ storm/event.py 2024-03-13 16:26:38 +0000 | |||
185 | @@ -26,7 +26,7 @@ | |||
186 | 26 | __all__ = ["EventSystem"] | 26 | __all__ = ["EventSystem"] |
187 | 27 | 27 | ||
188 | 28 | 28 | ||
190 | 29 | class EventSystem(object): | 29 | class EventSystem: |
191 | 30 | """A system for managing hooks that are called when events are emitted. | 30 | """A system for managing hooks that are called when events are emitted. |
192 | 31 | 31 | ||
193 | 32 | Hooks are callables that take the event system C{owner} as their first | 32 | Hooks are callables that take the event system C{owner} as their first |
194 | 33 | 33 | ||
195 | === modified file 'storm/expr.py' | |||
196 | --- storm/expr.py 2024-03-04 10:59:55 +0000 | |||
197 | +++ storm/expr.py 2024-03-13 16:26:38 +0000 | |||
198 | @@ -45,7 +45,7 @@ | |||
199 | 45 | return decorator | 45 | return decorator |
200 | 46 | 46 | ||
201 | 47 | 47 | ||
203 | 48 | class Compile(object): | 48 | class Compile: |
204 | 49 | """Compiler based on the concept of generic functions.""" | 49 | """Compiler based on the concept of generic functions.""" |
205 | 50 | 50 | ||
206 | 51 | def __init__(self, parent=None): | 51 | def __init__(self, parent=None): |
207 | @@ -145,7 +145,7 @@ | |||
208 | 145 | return "(%s)" % statement | 145 | return "(%s)" % statement |
209 | 146 | return statement | 146 | return statement |
210 | 147 | 147 | ||
212 | 148 | def __call__(self, expr, state=None, join=u", ", raw=False, token=False): | 148 | def __call__(self, expr, state=None, join=", ", raw=False, token=False): |
213 | 149 | """Compile the given expression into a SQL statement. | 149 | """Compile the given expression into a SQL statement. |
214 | 150 | 150 | ||
215 | 151 | @param expr: The expression to compile. | 151 | @param expr: The expression to compile. |
216 | @@ -217,7 +217,7 @@ | |||
217 | 217 | return namespace['closure'](state.parameters, bool) | 217 | return namespace['closure'](state.parameters, bool) |
218 | 218 | 218 | ||
219 | 219 | 219 | ||
221 | 220 | class State(object): | 220 | class State: |
222 | 221 | """All the data necessary during compilation of an expression. | 221 | """All the data necessary during compilation of an expression. |
223 | 222 | 222 | ||
224 | 223 | @ivar aliases: Dict of L{Column} instances to L{Alias} instances, | 223 | @ivar aliases: Dict of L{Column} instances to L{Alias} instances, |
225 | @@ -276,7 +276,7 @@ | |||
226 | 276 | # -------------------------------------------------------------------- | 276 | # -------------------------------------------------------------------- |
227 | 277 | # Expression contexts | 277 | # Expression contexts |
228 | 278 | 278 | ||
230 | 279 | class Context(object): | 279 | class Context: |
231 | 280 | """ | 280 | """ |
232 | 281 | An object used to specify the nature of expected SQL expressions | 281 | An object used to specify the nature of expected SQL expressions |
233 | 282 | being compiled in a given context. | 282 | being compiled in a given context. |
234 | @@ -395,13 +395,13 @@ | |||
235 | 395 | # A translation table that can escape a unicode string for use in a | 395 | # A translation table that can escape a unicode string for use in a |
236 | 396 | # Like() expression that uses "!" as the escape character. | 396 | # Like() expression that uses "!" as the escape character. |
237 | 397 | like_escape = { | 397 | like_escape = { |
241 | 398 | ord(u"!"): u"!!", | 398 | ord("!"): "!!", |
242 | 399 | ord(u"_"): u"!_", | 399 | ord("_"): "!_", |
243 | 400 | ord(u"%"): u"!%" | 400 | ord("%"): "!%" |
244 | 401 | } | 401 | } |
245 | 402 | 402 | ||
246 | 403 | 403 | ||
248 | 404 | class Comparable(object): | 404 | class Comparable: |
249 | 405 | __slots__ = () | 405 | __slots__ = () |
250 | 406 | __hash__ = object.__hash__ | 406 | __hash__ = object.__hash__ |
251 | 407 | 407 | ||
252 | @@ -511,20 +511,20 @@ | |||
253 | 511 | def startswith(self, prefix, case_sensitive=None): | 511 | def startswith(self, prefix, case_sensitive=None): |
254 | 512 | if not isinstance(prefix, str): | 512 | if not isinstance(prefix, str): |
255 | 513 | raise ExprError("Expected text argument, got %r" % type(prefix)) | 513 | raise ExprError("Expected text argument, got %r" % type(prefix)) |
258 | 514 | pattern = prefix.translate(like_escape) + u"%" | 514 | pattern = prefix.translate(like_escape) + "%" |
259 | 515 | return Like(self, pattern, u"!", case_sensitive) | 515 | return Like(self, pattern, "!", case_sensitive) |
260 | 516 | 516 | ||
261 | 517 | def endswith(self, suffix, case_sensitive=None): | 517 | def endswith(self, suffix, case_sensitive=None): |
262 | 518 | if not isinstance(suffix, str): | 518 | if not isinstance(suffix, str): |
263 | 519 | raise ExprError("Expected text argument, got %r" % type(suffix)) | 519 | raise ExprError("Expected text argument, got %r" % type(suffix)) |
266 | 520 | pattern = u"%" + suffix.translate(like_escape) | 520 | pattern = "%" + suffix.translate(like_escape) |
267 | 521 | return Like(self, pattern, u"!", case_sensitive) | 521 | return Like(self, pattern, "!", case_sensitive) |
268 | 522 | 522 | ||
269 | 523 | def contains_string(self, substring, case_sensitive=None): | 523 | def contains_string(self, substring, case_sensitive=None): |
270 | 524 | if not isinstance(substring, str): | 524 | if not isinstance(substring, str): |
271 | 525 | raise ExprError("Expected text argument, got %r" % type(substring)) | 525 | raise ExprError("Expected text argument, got %r" % type(substring)) |
274 | 526 | pattern = u"%" + substring.translate(like_escape) + u"%" | 526 | pattern = "%" + substring.translate(like_escape) + "%" |
275 | 527 | return Like(self, pattern, u"!", case_sensitive) | 527 | return Like(self, pattern, "!", case_sensitive) |
276 | 528 | 528 | ||
277 | 529 | 529 | ||
278 | 530 | class ComparableExpr(Expr, Comparable): | 530 | class ComparableExpr(Expr, Comparable): |
279 | @@ -584,7 +584,7 @@ | |||
280 | 584 | break | 584 | break |
281 | 585 | else: | 585 | else: |
282 | 586 | if tables is state.auto_tables: | 586 | if tables is state.auto_tables: |
284 | 587 | tables = set(compile(table, state, token=True) for table in tables) | 587 | tables = {compile(table, state, token=True) for table in tables} |
285 | 588 | return ", ".join(sorted(tables)) | 588 | return ", ".join(sorted(tables)) |
286 | 589 | else: | 589 | else: |
287 | 590 | return compile(tables, state, token=True) | 590 | return compile(tables, state, token=True) |
288 | 591 | 591 | ||
289 | === modified file 'storm/info.py' | |||
290 | --- storm/info.py 2024-03-04 10:59:55 +0000 | |||
291 | +++ storm/info.py 2024-03-13 16:26:38 +0000 | |||
292 | @@ -114,12 +114,10 @@ | |||
293 | 114 | 114 | ||
294 | 115 | # columns have __eq__ implementations that do things we don't want - we | 115 | # columns have __eq__ implementations that do things we don't want - we |
295 | 116 | # want to look these up in a dict and use identity semantics | 116 | # want to look these up in a dict and use identity semantics |
298 | 117 | id_positions = dict((id(column), i) | 117 | id_positions = {id(column): i for i, column in enumerate(self.columns)} |
297 | 118 | for i, column in enumerate(self.columns)) | ||
299 | 119 | 118 | ||
303 | 120 | self.primary_key_idx = dict((id(column), i) | 119 | self.primary_key_idx = {id(column): i |
304 | 121 | for i, column in | 120 | for i, column in enumerate(self.primary_key)} |
302 | 122 | enumerate(self.primary_key)) | ||
305 | 123 | self.primary_key_pos = tuple(id_positions[id(column)] | 121 | self.primary_key_pos = tuple(id_positions[id(column)] |
306 | 124 | for column in self.primary_key) | 122 | for column in self.primary_key) |
307 | 125 | 123 | ||
308 | @@ -202,7 +200,7 @@ | |||
309 | 202 | from storm.cextensions import ObjectInfo, get_obj_info | 200 | from storm.cextensions import ObjectInfo, get_obj_info |
310 | 203 | 201 | ||
311 | 204 | 202 | ||
313 | 205 | class ClassAlias(object): | 203 | class ClassAlias: |
314 | 206 | """Create a named alias for a Storm class for use in queries. | 204 | """Create a named alias for a Storm class for use in queries. |
315 | 207 | 205 | ||
316 | 208 | This is useful basically when the SQL 'AS' feature is desired in code using | 206 | This is useful basically when the SQL 'AS' feature is desired in code using |
317 | 209 | 207 | ||
318 | === modified file 'storm/properties.py' | |||
319 | --- storm/properties.py 2024-03-04 10:59:55 +0000 | |||
320 | +++ storm/properties.py 2024-03-13 16:26:38 +0000 | |||
321 | @@ -39,7 +39,7 @@ | |||
322 | 39 | "Pickle", "JSON", "List", "PropertyRegistry"] | 39 | "Pickle", "JSON", "List", "PropertyRegistry"] |
323 | 40 | 40 | ||
324 | 41 | 41 | ||
326 | 42 | class Property(object): | 42 | class Property: |
327 | 43 | """A property representing a database column. | 43 | """A property representing a database column. |
328 | 44 | 44 | ||
329 | 45 | Properties can be set as attributes of classes that have a | 45 | Properties can be set as attributes of classes that have a |
330 | @@ -363,7 +363,7 @@ | |||
331 | 363 | 363 | ||
332 | 364 | def __init__(self, name=None, primary=False, **kwargs): | 364 | def __init__(self, name=None, primary=False, **kwargs): |
333 | 365 | set_map = dict(kwargs.pop("map")) | 365 | set_map = dict(kwargs.pop("map")) |
335 | 366 | get_map = dict((value, key) for key, value in set_map.items()) | 366 | get_map = {value: key for key, value in set_map.items()} |
336 | 367 | if "set_map" in kwargs: | 367 | if "set_map" in kwargs: |
337 | 368 | set_map = dict(kwargs.pop("set_map")) | 368 | set_map = dict(kwargs.pop("set_map")) |
338 | 369 | 369 | ||
339 | @@ -372,7 +372,7 @@ | |||
340 | 372 | SimpleProperty.__init__(self, name, primary, **kwargs) | 372 | SimpleProperty.__init__(self, name, primary, **kwargs) |
341 | 373 | 373 | ||
342 | 374 | 374 | ||
344 | 375 | class PropertyRegistry(object): | 375 | class PropertyRegistry: |
345 | 376 | """ | 376 | """ |
346 | 377 | An object which remembers the Storm properties specified on | 377 | An object which remembers the Storm properties specified on |
347 | 378 | classes, and is able to translate names to these properties. | 378 | classes, and is able to translate names to these properties. |
348 | 379 | 379 | ||
349 | === modified file 'storm/references.py' | |||
350 | --- storm/references.py 2024-03-04 10:59:55 +0000 | |||
351 | +++ storm/references.py 2024-03-13 16:26:38 +0000 | |||
352 | @@ -33,7 +33,7 @@ | |||
353 | 33 | __all__ = ["Reference", "ReferenceSet", "Proxy"] | 33 | __all__ = ["Reference", "ReferenceSet", "Proxy"] |
354 | 34 | 34 | ||
355 | 35 | 35 | ||
357 | 36 | class LazyAttribute(object): | 36 | class LazyAttribute: |
358 | 37 | """ | 37 | """ |
359 | 38 | This descriptor will call the named attribute builder to | 38 | This descriptor will call the named attribute builder to |
360 | 39 | initialize the given attribute on first access. It avoids | 39 | initialize the given attribute on first access. It avoids |
361 | @@ -63,7 +63,7 @@ | |||
362 | 63 | PendingReferenceValue = PendingReferenceValue() | 63 | PendingReferenceValue = PendingReferenceValue() |
363 | 64 | 64 | ||
364 | 65 | 65 | ||
366 | 66 | class Reference(object): | 66 | class Reference: |
367 | 67 | """Descriptor for one-to-one relationships. | 67 | """Descriptor for one-to-one relationships. |
368 | 68 | 68 | ||
369 | 69 | This is typically used when the class that it is being defined on | 69 | This is typically used when the class that it is being defined on |
370 | @@ -212,7 +212,7 @@ | |||
371 | 212 | __hash__ = object.__hash__ | 212 | __hash__ = object.__hash__ |
372 | 213 | 213 | ||
373 | 214 | 214 | ||
375 | 215 | class ReferenceSet(object): | 215 | class ReferenceSet: |
376 | 216 | """Descriptor for many-to-one and many-to-many reference sets. | 216 | """Descriptor for many-to-one and many-to-many reference sets. |
377 | 217 | 217 | ||
378 | 218 | This is typically used when another class has a foreign key onto the | 218 | This is typically used when another class has a foreign key onto the |
379 | @@ -335,7 +335,7 @@ | |||
380 | 335 | self._relation2 = None | 335 | self._relation2 = None |
381 | 336 | 336 | ||
382 | 337 | 337 | ||
384 | 338 | class BoundReferenceSetBase(object): | 338 | class BoundReferenceSetBase: |
385 | 339 | 339 | ||
386 | 340 | def find(self, *args, **kwargs): | 340 | def find(self, *args, **kwargs): |
387 | 341 | store = Store.of(self._local) | 341 | store = Store.of(self._local) |
388 | @@ -471,7 +471,7 @@ | |||
389 | 471 | a native property of C{Foo}. | 471 | a native property of C{Foo}. |
390 | 472 | """ | 472 | """ |
391 | 473 | 473 | ||
393 | 474 | class RemoteProp(object): | 474 | class RemoteProp: |
394 | 475 | """ | 475 | """ |
395 | 476 | This descriptor will resolve and set the _remote_prop attribute | 476 | This descriptor will resolve and set the _remote_prop attribute |
396 | 477 | when it's first used. It avoids having a test at every single | 477 | when it's first used. It avoids having a test at every single |
397 | @@ -517,7 +517,7 @@ | |||
398 | 517 | return compile(proxy._remote_prop, state) | 517 | return compile(proxy._remote_prop, state) |
399 | 518 | 518 | ||
400 | 519 | 519 | ||
402 | 520 | class Relation(object): | 520 | class Relation: |
403 | 521 | 521 | ||
404 | 522 | def __init__(self, local_key, remote_key, many, on_remote): | 522 | def __init__(self, local_key, remote_key, many, on_remote): |
405 | 523 | assert type(local_key) is tuple and type(remote_key) is tuple | 523 | assert type(local_key) is tuple and type(remote_key) is tuple |
406 | @@ -963,7 +963,7 @@ | |||
407 | 963 | return self._r_to_l.setdefault(local_cls, map).get(remote_column) | 963 | return self._r_to_l.setdefault(local_cls, map).get(remote_column) |
408 | 964 | 964 | ||
409 | 965 | 965 | ||
411 | 966 | class PropertyResolver(object): | 966 | class PropertyResolver: |
412 | 967 | """Transform strings and pure properties (non-columns) into columns.""" | 967 | """Transform strings and pure properties (non-columns) into columns.""" |
413 | 968 | 968 | ||
414 | 969 | def __init__(self, reference, used_cls): | 969 | def __init__(self, reference, used_cls): |
415 | 970 | 970 | ||
416 | === modified file 'storm/schema/patch.py' | |||
417 | --- storm/schema/patch.py 2024-03-04 10:59:55 +0000 | |||
418 | +++ storm/schema/patch.py 2024-03-13 16:26:38 +0000 | |||
419 | @@ -61,7 +61,7 @@ | |||
420 | 61 | """Raised when a patch failing with a random exception is found.""" | 61 | """Raised when a patch failing with a random exception is found.""" |
421 | 62 | 62 | ||
422 | 63 | 63 | ||
424 | 64 | class Patch(object): | 64 | class Patch: |
425 | 65 | """Database object representing an applied patch. | 65 | """Database object representing an applied patch. |
426 | 66 | 66 | ||
427 | 67 | @version: The version of the patch associated with this object. | 67 | @version: The version of the patch associated with this object. |
428 | @@ -75,7 +75,7 @@ | |||
429 | 75 | self.version = version | 75 | self.version = version |
430 | 76 | 76 | ||
431 | 77 | 77 | ||
433 | 78 | class PatchApplier(object): | 78 | class PatchApplier: |
434 | 79 | """Apply to a L{Store} the database patches from a given Python package. | 79 | """Apply to a L{Store} the database patches from a given Python package. |
435 | 80 | 80 | ||
436 | 81 | @param store: The L{Store} to apply the patches to. | 81 | @param store: The L{Store} to apply the patches to. |
437 | @@ -189,7 +189,7 @@ | |||
438 | 189 | return applied | 189 | return applied |
439 | 190 | 190 | ||
440 | 191 | 191 | ||
442 | 192 | class PatchSet(object): | 192 | class PatchSet: |
443 | 193 | """A collection of patch modules. | 193 | """A collection of patch modules. |
444 | 194 | 194 | ||
445 | 195 | Each patch module lives in a regular Python module file, contained in a | 195 | Each patch module lives in a regular Python module file, contained in a |
446 | @@ -269,7 +269,7 @@ | |||
447 | 269 | return os.path.dirname(self._package.__file__) | 269 | return os.path.dirname(self._package.__file__) |
448 | 270 | 270 | ||
449 | 271 | 271 | ||
451 | 272 | class _EmptyPatchModule(object): | 272 | class _EmptyPatchModule: |
452 | 273 | """Fake module object with a no-op C{apply} function.""" | 273 | """Fake module object with a no-op C{apply} function.""" |
453 | 274 | 274 | ||
454 | 275 | def apply(self, store): | 275 | def apply(self, store): |
455 | 276 | 276 | ||
456 | === modified file 'storm/schema/schema.py' | |||
457 | --- storm/schema/schema.py 2024-03-04 10:59:55 +0000 | |||
458 | +++ storm/schema/schema.py 2024-03-13 16:26:38 +0000 | |||
459 | @@ -63,7 +63,7 @@ | |||
460 | 63 | self.unapplied_versions = unapplied_versions | 63 | self.unapplied_versions = unapplied_versions |
461 | 64 | 64 | ||
462 | 65 | 65 | ||
464 | 66 | class Schema(object): | 66 | class Schema: |
465 | 67 | """Create, drop, clean and patch table schemas. | 67 | """Create, drop, clean and patch table schemas. |
466 | 68 | 68 | ||
467 | 69 | @param creates: A list of C{CREATE TABLE} statements. | 69 | @param creates: A list of C{CREATE TABLE} statements. |
468 | @@ -194,7 +194,7 @@ | |||
469 | 194 | return PatchApplier(store, self._patch_set, committer) | 194 | return PatchApplier(store, self._patch_set, committer) |
470 | 195 | 195 | ||
471 | 196 | 196 | ||
473 | 197 | class _NoopCommitter(object): | 197 | class _NoopCommitter: |
474 | 198 | """Dummy committer that does nothing.""" | 198 | """Dummy committer that does nothing.""" |
475 | 199 | 199 | ||
476 | 200 | def commit(self): | 200 | def commit(self): |
477 | 201 | 201 | ||
478 | === modified file 'storm/schema/sharding.py' | |||
479 | --- storm/schema/sharding.py 2024-03-04 10:59:55 +0000 | |||
480 | +++ storm/schema/sharding.py 2024-03-13 16:26:38 +0000 | |||
481 | @@ -48,7 +48,7 @@ | |||
482 | 48 | """Raised when stores don't have all the same patch level.""" | 48 | """Raised when stores don't have all the same patch level.""" |
483 | 49 | 49 | ||
484 | 50 | 50 | ||
486 | 51 | class Sharding(object): | 51 | class Sharding: |
487 | 52 | """Manage L{Shema}s over a collection of L{Store}s.""" | 52 | """Manage L{Shema}s over a collection of L{Store}s.""" |
488 | 53 | 53 | ||
489 | 54 | def __init__(self): | 54 | def __init__(self): |
490 | 55 | 55 | ||
491 | === modified file 'storm/sqlobject.py' | |||
492 | --- storm/sqlobject.py 2024-03-04 10:59:55 +0000 | |||
493 | +++ storm/sqlobject.py 2024-03-13 16:26:38 +0000 | |||
494 | @@ -61,7 +61,7 @@ | |||
495 | 61 | pass | 61 | pass |
496 | 62 | 62 | ||
497 | 63 | 63 | ||
499 | 64 | class SQLObjectStyle(object): | 64 | class SQLObjectStyle: |
500 | 65 | 65 | ||
501 | 66 | longID = False | 66 | longID = False |
502 | 67 | 67 | ||
503 | @@ -212,7 +212,7 @@ | |||
504 | 212 | attr_to_prop[id_name] = "id" | 212 | attr_to_prop[id_name] = "id" |
505 | 213 | 213 | ||
506 | 214 | # Notice that obj is the class since this is the metaclass. | 214 | # Notice that obj is the class since this is the metaclass. |
508 | 215 | obj = super(SQLObjectMeta, cls).__new__(cls, name, bases, dict) | 215 | obj = super().__new__(cls, name, bases, dict) |
509 | 216 | 216 | ||
510 | 217 | property_registry = obj._storm_property_registry | 217 | property_registry = obj._storm_property_registry |
511 | 218 | 218 | ||
512 | @@ -239,14 +239,14 @@ | |||
513 | 239 | return obj | 239 | return obj |
514 | 240 | 240 | ||
515 | 241 | 241 | ||
517 | 242 | class DotQ(object): | 242 | class DotQ: |
518 | 243 | """A descriptor that mimics the SQLObject 'Table.q' syntax""" | 243 | """A descriptor that mimics the SQLObject 'Table.q' syntax""" |
519 | 244 | 244 | ||
520 | 245 | def __get__(self, obj, cls=None): | 245 | def __get__(self, obj, cls=None): |
521 | 246 | return BoundDotQ(cls) | 246 | return BoundDotQ(cls) |
522 | 247 | 247 | ||
523 | 248 | 248 | ||
525 | 249 | class BoundDotQ(object): | 249 | class BoundDotQ: |
526 | 250 | 250 | ||
527 | 251 | def __init__(self, cls): | 251 | def __init__(self, cls): |
528 | 252 | self._cls = cls | 252 | self._cls = cls |
529 | @@ -374,7 +374,7 @@ | |||
530 | 374 | store.autoreload(self) | 374 | store.autoreload(self) |
531 | 375 | 375 | ||
532 | 376 | 376 | ||
534 | 377 | class SQLObjectResultSet(object): | 377 | class SQLObjectResultSet: |
535 | 378 | """SQLObject-equivalent of the ResultSet class in Storm. | 378 | """SQLObject-equivalent of the ResultSet class in Storm. |
536 | 379 | 379 | ||
537 | 380 | Storm handles joins in the Store interface, while SQLObject | 380 | Storm handles joins in the Store interface, while SQLObject |
538 | @@ -638,7 +638,7 @@ | |||
539 | 638 | 638 | ||
540 | 639 | 639 | ||
541 | 640 | 640 | ||
543 | 641 | class PropertyAdapter(object): | 641 | class PropertyAdapter: |
544 | 642 | 642 | ||
545 | 643 | _kwargs = {} | 643 | _kwargs = {} |
546 | 644 | 644 | ||
547 | @@ -668,11 +668,11 @@ | |||
548 | 668 | default = Undef | 668 | default = Undef |
549 | 669 | else: | 669 | else: |
550 | 670 | default_factory = Undef | 670 | default_factory = Undef |
556 | 671 | super(PropertyAdapter, self).__init__(dbName, allow_none=not notNull, | 671 | super().__init__(dbName, allow_none=not notNull, |
557 | 672 | default_factory=default_factory, | 672 | default_factory=default_factory, |
558 | 673 | default=default, | 673 | default=default, |
559 | 674 | validator=storm_validator, | 674 | validator=storm_validator, |
560 | 675 | **self._kwargs) | 675 | **self._kwargs) |
561 | 676 | 676 | ||
562 | 677 | 677 | ||
563 | 678 | # DEPRECATED: On Python 2, this used to be a more relaxed version of | 678 | # DEPRECATED: On Python 2, this used to be a more relaxed version of |
564 | @@ -708,7 +708,7 @@ | |||
565 | 708 | pass | 708 | pass |
566 | 709 | 709 | ||
567 | 710 | 710 | ||
569 | 711 | class ForeignKey(object): | 711 | class ForeignKey: |
570 | 712 | 712 | ||
571 | 713 | def __init__(self, foreignKey, **kwargs): | 713 | def __init__(self, foreignKey, **kwargs): |
572 | 714 | self.foreignKey = foreignKey | 714 | self.foreignKey = foreignKey |
573 | @@ -753,7 +753,7 @@ | |||
574 | 753 | class SingleJoin(Reference): | 753 | class SingleJoin(Reference): |
575 | 754 | 754 | ||
576 | 755 | def __init__(self, otherClass, joinColumn, prejoins=_IGNORED): | 755 | def __init__(self, otherClass, joinColumn, prejoins=_IGNORED): |
578 | 756 | super(SingleJoin, self).__init__( | 756 | super().__init__( |
579 | 757 | "<primary key>", "%s.%s" % (otherClass, joinColumn), | 757 | "<primary key>", "%s.%s" % (otherClass, joinColumn), |
580 | 758 | on_remote=True) | 758 | on_remote=True) |
581 | 759 | 759 | ||
582 | 760 | 760 | ||
583 | === modified file 'storm/store.py' | |||
584 | --- storm/store.py 2024-03-04 10:59:55 +0000 | |||
585 | +++ storm/store.py 2024-03-13 16:26:38 +0000 | |||
586 | @@ -55,7 +55,7 @@ | |||
587 | 55 | PENDING_REMOVE = 2 | 55 | PENDING_REMOVE = 2 |
588 | 56 | 56 | ||
589 | 57 | 57 | ||
591 | 58 | class Store(object): | 58 | class Store: |
592 | 59 | """The Storm Store. | 59 | """The Storm Store. |
593 | 60 | 60 | ||
594 | 61 | This is the highest-level interface to a database. It manages | 61 | This is the highest-level interface to a database. It manages |
595 | @@ -479,7 +479,7 @@ | |||
596 | 479 | if n > 0: | 479 | if n > 0: |
597 | 480 | before_set = predecessors.get(after_info) | 480 | before_set = predecessors.get(after_info) |
598 | 481 | if before_set is None: | 481 | if before_set is None: |
600 | 482 | predecessors[after_info] = set((before_info,)) | 482 | predecessors[after_info] = {before_info} |
601 | 483 | else: | 483 | else: |
602 | 484 | before_set.add(before_info) | 484 | before_set.add(before_info) |
603 | 485 | 485 | ||
604 | @@ -918,7 +918,7 @@ | |||
605 | 918 | result, result.get_one()) | 918 | result, result.get_one()) |
606 | 919 | 919 | ||
607 | 920 | 920 | ||
609 | 921 | class ResultSet(object): | 921 | class ResultSet: |
610 | 922 | """The representation of the results of a query. | 922 | """The representation of the results of a query. |
611 | 923 | 923 | ||
612 | 924 | Note that having an instance of this class does not indicate that | 924 | Note that having an instance of this class does not indicate that |
613 | @@ -1518,7 +1518,7 @@ | |||
614 | 1518 | return self._set_expr(Intersect, other, all) | 1518 | return self._set_expr(Intersect, other, all) |
615 | 1519 | 1519 | ||
616 | 1520 | 1520 | ||
618 | 1521 | class EmptyResultSet(object): | 1521 | class EmptyResultSet: |
619 | 1522 | """An object that looks like a L{ResultSet} but represents no rows. | 1522 | """An object that looks like a L{ResultSet} but represents no rows. |
620 | 1523 | 1523 | ||
621 | 1524 | This is convenient for application developers who want to provide | 1524 | This is convenient for application developers who want to provide |
622 | @@ -1645,7 +1645,7 @@ | |||
623 | 1645 | return self | 1645 | return self |
624 | 1646 | 1646 | ||
625 | 1647 | 1647 | ||
627 | 1648 | class TableSet(object): | 1648 | class TableSet: |
628 | 1649 | """The representation of a set of tables which can be queried at once. | 1649 | """The representation of a set of tables which can be queried at once. |
629 | 1650 | 1650 | ||
630 | 1651 | This will typically be constructed by a call to L{Store.using}. | 1651 | This will typically be constructed by a call to L{Store.using}. |
631 | @@ -1675,7 +1675,7 @@ | |||
632 | 1675 | Store._table_set = TableSet | 1675 | Store._table_set = TableSet |
633 | 1676 | 1676 | ||
634 | 1677 | 1677 | ||
636 | 1678 | class FindSpec(object): | 1678 | class FindSpec: |
637 | 1679 | """The set of tables or expressions in the result of L{Store.find}.""" | 1679 | """The set of tables or expressions in the result of L{Store.find}.""" |
638 | 1680 | 1680 | ||
639 | 1681 | def __init__(self, cls_spec): | 1681 | def __init__(self, cls_spec): |
640 | @@ -1859,7 +1859,7 @@ | |||
641 | 1859 | AutoReload = AutoReload() | 1859 | AutoReload = AutoReload() |
642 | 1860 | 1860 | ||
643 | 1861 | 1861 | ||
645 | 1862 | class block_access(object): | 1862 | class block_access: |
646 | 1863 | """ | 1863 | """ |
647 | 1864 | Context manager blocks database access by one or more L{Store}\\ s in the | 1864 | Context manager blocks database access by one or more L{Store}\\ s in the |
648 | 1865 | managed scope. | 1865 | managed scope. |
649 | 1866 | 1866 | ||
650 | === modified file 'storm/testing.py' | |||
651 | --- storm/testing.py 2024-03-04 10:59:55 +0000 | |||
652 | +++ storm/testing.py 2024-03-13 16:26:38 +0000 | |||
653 | @@ -16,7 +16,7 @@ | |||
654 | 16 | """ | 16 | """ |
655 | 17 | 17 | ||
656 | 18 | def __init__(self): | 18 | def __init__(self): |
658 | 19 | super(CaptureTracer, self).__init__() | 19 | super().__init__() |
659 | 20 | self.queries = [] | 20 | self.queries = [] |
660 | 21 | 21 | ||
661 | 22 | def _setUp(self): | 22 | def _setUp(self): |
662 | 23 | 23 | ||
663 | === modified file 'storm/tests/cache.py' | |||
664 | --- storm/tests/cache.py 2024-03-04 10:59:55 +0000 | |||
665 | +++ storm/tests/cache.py 2024-03-13 16:26:38 +0000 | |||
666 | @@ -6,7 +6,7 @@ | |||
667 | 6 | from storm.tests.helper import TestHelper | 6 | from storm.tests.helper import TestHelper |
668 | 7 | 7 | ||
669 | 8 | 8 | ||
671 | 9 | class StubObjectInfo(object): | 9 | class StubObjectInfo: |
672 | 10 | 10 | ||
673 | 11 | def __init__(self, id): | 11 | def __init__(self, id): |
674 | 12 | self.id = id | 12 | self.id = id |
675 | @@ -26,7 +26,7 @@ | |||
676 | 26 | return self.id < other.id | 26 | return self.id < other.id |
677 | 27 | 27 | ||
678 | 28 | 28 | ||
680 | 29 | class StubClass(object): | 29 | class StubClass: |
681 | 30 | 30 | ||
682 | 31 | __storm_table__ = "stub_class" | 31 | __storm_table__ = "stub_class" |
683 | 32 | 32 | ||
684 | @@ -38,7 +38,7 @@ | |||
685 | 38 | Cache = Cache | 38 | Cache = Cache |
686 | 39 | 39 | ||
687 | 40 | def setUp(self): | 40 | def setUp(self): |
689 | 41 | super(BaseCacheTest, self).setUp() | 41 | super().setUp() |
690 | 42 | self.obj_infos = [StubObjectInfo(i) for i in range(10)] | 42 | self.obj_infos = [StubObjectInfo(i) for i in range(10)] |
691 | 43 | for i in range(len(self.obj_infos)): | 43 | for i in range(len(self.obj_infos)): |
692 | 44 | setattr(self, "obj%d" % (i+1), self.obj_infos[i]) | 44 | setattr(self, "obj%d" % (i+1), self.obj_infos[i]) |
693 | @@ -194,7 +194,7 @@ | |||
694 | 194 | Cache = GenerationalCache | 194 | Cache = GenerationalCache |
695 | 195 | 195 | ||
696 | 196 | def setUp(self): | 196 | def setUp(self): |
698 | 197 | super(TestGenerationalCache, self).setUp() | 197 | super().setUp() |
699 | 198 | self.obj1 = StubObjectInfo(1) | 198 | self.obj1 = StubObjectInfo(1) |
700 | 199 | self.obj2 = StubObjectInfo(2) | 199 | self.obj2 = StubObjectInfo(2) |
701 | 200 | self.obj3 = StubObjectInfo(3) | 200 | self.obj3 = StubObjectInfo(3) |
702 | 201 | 201 | ||
703 | === modified file 'storm/tests/database.py' | |||
704 | --- storm/tests/database.py 2024-03-04 10:59:55 +0000 | |||
705 | +++ storm/tests/database.py 2024-03-13 16:26:38 +0000 | |||
706 | @@ -36,7 +36,7 @@ | |||
707 | 36 | marker = object() | 36 | marker = object() |
708 | 37 | 37 | ||
709 | 38 | 38 | ||
711 | 39 | class RawConnection(object): | 39 | class RawConnection: |
712 | 40 | 40 | ||
713 | 41 | closed = False | 41 | closed = False |
714 | 42 | 42 | ||
715 | @@ -56,7 +56,7 @@ | |||
716 | 56 | self.executed.append("CCLOSE") | 56 | self.executed.append("CCLOSE") |
717 | 57 | 57 | ||
718 | 58 | 58 | ||
720 | 59 | class RawCursor(object): | 59 | class RawCursor: |
721 | 60 | 60 | ||
722 | 61 | def __init__(self, arraysize=1, executed=None): | 61 | def __init__(self, arraysize=1, executed=None): |
723 | 62 | self.arraysize = arraysize | 62 | self.arraysize = arraysize |
724 | @@ -91,7 +91,7 @@ | |||
725 | 91 | return result | 91 | return result |
726 | 92 | 92 | ||
727 | 93 | 93 | ||
729 | 94 | class FakeConnection(object): | 94 | class FakeConnection: |
730 | 95 | 95 | ||
731 | 96 | def __init__(self): | 96 | def __init__(self): |
732 | 97 | self._database = Database() | 97 | self._database = Database() |
733 | @@ -100,7 +100,7 @@ | |||
734 | 100 | return _function(*args, **kwargs) | 100 | return _function(*args, **kwargs) |
735 | 101 | 101 | ||
736 | 102 | 102 | ||
738 | 103 | class FakeTracer(object): | 103 | class FakeTracer: |
739 | 104 | 104 | ||
740 | 105 | def __init__(self, stream=None): | 105 | def __init__(self, stream=None): |
741 | 106 | self.seen = [] | 106 | self.seen = [] |
742 | @@ -538,7 +538,7 @@ | |||
743 | 538 | self.assertEqual(self.uri.database, "db") | 538 | self.assertEqual(self.uri.database, "db") |
744 | 539 | 539 | ||
745 | 540 | def test_create_database_with_unicode(self): | 540 | def test_create_database_with_unicode(self): |
747 | 541 | create_database(u"db_module:db") | 541 | create_database("db_module:db") |
748 | 542 | self.assertTrue(self.uri) | 542 | self.assertTrue(self.uri) |
749 | 543 | self.assertEqual(self.uri.scheme, "db_module") | 543 | self.assertEqual(self.uri.scheme, "db_module") |
750 | 544 | self.assertEqual(self.uri.database, "db") | 544 | self.assertEqual(self.uri.database, "db") |
751 | 545 | 545 | ||
752 | === modified file 'storm/tests/databases/base.py' | |||
753 | --- storm/tests/databases/base.py 2024-03-04 10:59:55 +0000 | |||
754 | +++ storm/tests/databases/base.py 2024-03-13 16:26:38 +0000 | |||
755 | @@ -1,5 +1,3 @@ | |||
756 | 1 | |||
757 | 2 | # -*- encoding: utf-8 -*- | ||
758 | 3 | # | 1 | # |
759 | 4 | # Copyright (c) 2006, 2007 Canonical | 2 | # Copyright (c) 2006, 2007 Canonical |
760 | 5 | # | 3 | # |
761 | @@ -41,18 +39,18 @@ | |||
762 | 41 | from storm.tests.helper import MakePath | 39 | from storm.tests.helper import MakePath |
763 | 42 | 40 | ||
764 | 43 | 41 | ||
766 | 44 | class Marker(object): | 42 | class Marker: |
767 | 45 | pass | 43 | pass |
768 | 46 | 44 | ||
769 | 47 | marker = Marker() | 45 | marker = Marker() |
770 | 48 | 46 | ||
771 | 49 | 47 | ||
773 | 50 | class DatabaseTest(object): | 48 | class DatabaseTest: |
774 | 51 | 49 | ||
775 | 52 | supports_microseconds = True | 50 | supports_microseconds = True |
776 | 53 | 51 | ||
777 | 54 | def setUp(self): | 52 | def setUp(self): |
779 | 55 | super(DatabaseTest, self).setUp() | 53 | super().setUp() |
780 | 56 | self.create_database() | 54 | self.create_database() |
781 | 57 | self.create_connection() | 55 | self.create_connection() |
782 | 58 | self.drop_tables() | 56 | self.drop_tables() |
783 | @@ -64,7 +62,7 @@ | |||
784 | 64 | self.drop_tables() | 62 | self.drop_tables() |
785 | 65 | self.drop_connection() | 63 | self.drop_connection() |
786 | 66 | self.drop_database() | 64 | self.drop_database() |
788 | 67 | super(DatabaseTest, self).tearDown() | 65 | super().tearDown() |
789 | 68 | 66 | ||
790 | 69 | def create_database(self): | 67 | def create_database(self): |
791 | 70 | raise NotImplementedError | 68 | raise NotImplementedError |
792 | @@ -144,7 +142,7 @@ | |||
793 | 144 | self.assertTrue(result.get_one()) | 142 | self.assertTrue(result.get_one()) |
794 | 145 | 143 | ||
795 | 146 | def test_execute_unicode_result(self): | 144 | def test_execute_unicode_result(self): |
797 | 147 | result = self.connection.execute(u"SELECT title FROM test") | 145 | result = self.connection.execute("SELECT title FROM test") |
798 | 148 | self.assertTrue(isinstance(result, Result)) | 146 | self.assertTrue(isinstance(result, Result)) |
799 | 149 | row = result.get_one() | 147 | row = result.get_one() |
800 | 150 | self.assertEqual(row, ("Title 10",)) | 148 | self.assertEqual(row, ("Title 10",)) |
801 | @@ -213,7 +211,7 @@ | |||
802 | 213 | "VALUES ('Title 30')") | 211 | "VALUES ('Title 30')") |
803 | 214 | primary_key = (Column("id", SQLToken("test")), | 212 | primary_key = (Column("id", SQLToken("test")), |
804 | 215 | Column("title", SQLToken("test"))) | 213 | Column("title", SQLToken("test"))) |
806 | 216 | primary_variables = (Variable(), Variable(u"Title 30")) | 214 | primary_variables = (Variable(), Variable("Title 30")) |
807 | 217 | expr = result.get_insert_identity(primary_key, primary_variables) | 215 | expr = result.get_insert_identity(primary_key, primary_variables) |
808 | 218 | select = Select(Column("title", SQLToken("test")), expr) | 216 | select = Select(Column("title", SQLToken("test")), expr) |
809 | 219 | result = self.connection.execute(select) | 217 | result = self.connection.execute(select) |
810 | @@ -408,7 +406,7 @@ | |||
811 | 408 | self.connection.execute("INSERT INTO test VALUES (40, '!!blah')") | 406 | self.connection.execute("INSERT INTO test VALUES (40, '!!blah')") |
812 | 409 | id = Column("id", SQLToken("test")) | 407 | id = Column("id", SQLToken("test")) |
813 | 410 | title = Column("title", SQLToken("test")) | 408 | title = Column("title", SQLToken("test")) |
815 | 411 | expr = Select(id, title.startswith(u"!!_%")) | 409 | expr = Select(id, title.startswith("!!_%")) |
816 | 412 | result = list(self.connection.execute(expr)) | 410 | result = list(self.connection.execute(expr)) |
817 | 413 | self.assertEqual(result, [(30,)]) | 411 | self.assertEqual(result, [(30,)]) |
818 | 414 | 412 | ||
819 | @@ -417,7 +415,7 @@ | |||
820 | 417 | self.connection.execute("INSERT INTO test VALUES (40, 'blah!!')") | 415 | self.connection.execute("INSERT INTO test VALUES (40, 'blah!!')") |
821 | 418 | id = Column("id", SQLToken("test")) | 416 | id = Column("id", SQLToken("test")) |
822 | 419 | title = Column("title", SQLToken("test")) | 417 | title = Column("title", SQLToken("test")) |
824 | 420 | expr = Select(id, title.endswith(u"_%!!")) | 418 | expr = Select(id, title.endswith("_%!!")) |
825 | 421 | result = list(self.connection.execute(expr)) | 419 | result = list(self.connection.execute(expr)) |
826 | 422 | self.assertEqual(result, [(30,)]) | 420 | self.assertEqual(result, [(30,)]) |
827 | 423 | 421 | ||
828 | @@ -426,7 +424,7 @@ | |||
829 | 426 | self.connection.execute("INSERT INTO test VALUES (40, 'blah!!x')") | 424 | self.connection.execute("INSERT INTO test VALUES (40, 'blah!!x')") |
830 | 427 | id = Column("id", SQLToken("test")) | 425 | id = Column("id", SQLToken("test")) |
831 | 428 | title = Column("title", SQLToken("test")) | 426 | title = Column("title", SQLToken("test")) |
833 | 429 | expr = Select(id, title.contains_string(u"_%!!")) | 427 | expr = Select(id, title.contains_string("_%!!")) |
834 | 430 | result = list(self.connection.execute(expr)) | 428 | result = list(self.connection.execute(expr)) |
835 | 431 | self.assertEqual(result, [(30,)]) | 429 | self.assertEqual(result, [(30,)]) |
836 | 432 | 430 | ||
837 | @@ -459,10 +457,10 @@ | |||
838 | 459 | self.assertEqual(('error message',), wrapped.args) | 457 | self.assertEqual(('error message',), wrapped.args) |
839 | 460 | 458 | ||
840 | 461 | 459 | ||
842 | 462 | class TwoPhaseCommitTest(object): | 460 | class TwoPhaseCommitTest: |
843 | 463 | 461 | ||
844 | 464 | def setUp(self): | 462 | def setUp(self): |
846 | 465 | super(TwoPhaseCommitTest, self).setUp() | 463 | super().setUp() |
847 | 466 | self.create_database() | 464 | self.create_database() |
848 | 467 | self.create_connection() | 465 | self.create_connection() |
849 | 468 | self.drop_tables() | 466 | self.drop_tables() |
850 | @@ -471,7 +469,7 @@ | |||
851 | 471 | def tearDown(self): | 469 | def tearDown(self): |
852 | 472 | self.drop_tables() | 470 | self.drop_tables() |
853 | 473 | self.drop_connection() | 471 | self.drop_connection() |
855 | 474 | super(TwoPhaseCommitTest, self).tearDown() | 472 | super().tearDown() |
856 | 475 | 473 | ||
857 | 476 | def create_database(self): | 474 | def create_database(self): |
858 | 477 | raise NotImplementedError | 475 | raise NotImplementedError |
859 | @@ -630,7 +628,7 @@ | |||
860 | 630 | self.assertFalse(result.get_one()) | 628 | self.assertFalse(result.get_one()) |
861 | 631 | 629 | ||
862 | 632 | 630 | ||
864 | 633 | class UnsupportedDatabaseTest(object): | 631 | class UnsupportedDatabaseTest: |
865 | 634 | 632 | ||
866 | 635 | helpers = [MakePath] | 633 | helpers = [MakePath] |
867 | 636 | 634 | ||
868 | @@ -686,14 +684,14 @@ | |||
869 | 686 | sys.modules.update(dbapi_modules) | 684 | sys.modules.update(dbapi_modules) |
870 | 687 | 685 | ||
871 | 688 | 686 | ||
873 | 689 | class DatabaseDisconnectionMixin(object): | 687 | class DatabaseDisconnectionMixin: |
874 | 690 | 688 | ||
875 | 691 | environment_variable = "" | 689 | environment_variable = "" |
876 | 692 | host_environment_variable = "" | 690 | host_environment_variable = "" |
877 | 693 | default_port = None | 691 | default_port = None |
878 | 694 | 692 | ||
879 | 695 | def setUp(self): | 693 | def setUp(self): |
881 | 696 | super(DatabaseDisconnectionMixin, self).setUp() | 694 | super().setUp() |
882 | 697 | self.create_database_and_proxy() | 695 | self.create_database_and_proxy() |
883 | 698 | self.create_connection() | 696 | self.create_connection() |
884 | 699 | 697 | ||
885 | @@ -701,7 +699,7 @@ | |||
886 | 701 | self.drop_connection() | 699 | self.drop_connection() |
887 | 702 | self.drop_database() | 700 | self.drop_database() |
888 | 703 | self.proxy.close() | 701 | self.proxy.close() |
890 | 704 | super(DatabaseDisconnectionMixin, self).tearDown() | 702 | super().tearDown() |
891 | 705 | 703 | ||
892 | 706 | def is_supported(self): | 704 | def is_supported(self): |
893 | 707 | return bool(self.get_uri()) | 705 | return bool(self.get_uri()) |
894 | @@ -884,7 +882,7 @@ | |||
895 | 884 | self.connection.close() | 882 | self.connection.close() |
896 | 885 | 883 | ||
897 | 886 | 884 | ||
899 | 887 | class TwoPhaseCommitDisconnectionTest(object): | 885 | class TwoPhaseCommitDisconnectionTest: |
900 | 888 | 886 | ||
901 | 889 | def test_begin_after_rollback_with_disconnection_error(self): | 887 | def test_begin_after_rollback_with_disconnection_error(self): |
902 | 890 | """ | 888 | """ |
903 | 891 | 889 | ||
904 | === modified file 'storm/tests/databases/mysql.py' | |||
905 | --- storm/tests/databases/mysql.py 2024-03-04 10:59:55 +0000 | |||
906 | +++ storm/tests/databases/mysql.py 2024-03-13 16:26:38 +0000 | |||
907 | @@ -99,7 +99,7 @@ | |||
908 | 99 | id_column = Column("id", "test") | 99 | id_column = Column("id", "test") |
909 | 100 | id_variable = IntVariable() | 100 | id_variable = IntVariable() |
910 | 101 | title_column = Column("title", "test") | 101 | title_column = Column("title", "test") |
912 | 102 | title_variable = UnicodeVariable(u"testing") | 102 | title_variable = UnicodeVariable("testing") |
913 | 103 | 103 | ||
914 | 104 | # This is not part of the table. It is just used to show that | 104 | # This is not part of the table. It is just used to show that |
915 | 105 | # only one primary key variable is set from the insert ID. | 105 | # only one primary key variable is set from the insert ID. |
916 | @@ -161,4 +161,4 @@ | |||
917 | 161 | if "unix_socket" in uri.options: | 161 | if "unix_socket" in uri.options: |
918 | 162 | return create_proxy_and_uri(uri)[0] | 162 | return create_proxy_and_uri(uri)[0] |
919 | 163 | else: | 163 | else: |
921 | 164 | return super(MySQLDisconnectionTest, self).create_proxy(uri) | 164 | return super().create_proxy(uri) |
922 | 165 | 165 | ||
923 | === modified file 'storm/tests/databases/postgres.py' | |||
924 | --- storm/tests/databases/postgres.py 2024-03-04 10:59:55 +0000 | |||
925 | +++ storm/tests/databases/postgres.py 2024-03-13 16:26:38 +0000 | |||
926 | @@ -116,7 +116,7 @@ | |||
927 | 116 | " json JSON)") | 116 | " json JSON)") |
928 | 117 | 117 | ||
929 | 118 | def drop_tables(self): | 118 | def drop_tables(self): |
931 | 119 | super(PostgresTest, self).drop_tables() | 119 | super().drop_tables() |
932 | 120 | tables = ("like_case_insensitive_test", "returning_test", "json_test") | 120 | tables = ("like_case_insensitive_test", "returning_test", "json_test") |
933 | 121 | for table in tables: | 121 | for table in tables: |
934 | 122 | try: | 122 | try: |
935 | @@ -126,7 +126,7 @@ | |||
936 | 126 | self.connection.rollback() | 126 | self.connection.rollback() |
937 | 127 | 127 | ||
938 | 128 | def create_sample_data(self): | 128 | def create_sample_data(self): |
940 | 129 | super(PostgresTest, self).create_sample_data() | 129 | super().create_sample_data() |
941 | 130 | self.connection.execute("INSERT INTO like_case_insensitive_test " | 130 | self.connection.execute("INSERT INTO like_case_insensitive_test " |
942 | 131 | "(description) VALUES ('hullah')") | 131 | "(description) VALUES ('hullah')") |
943 | 132 | self.connection.execute("INSERT INTO like_case_insensitive_test " | 132 | self.connection.execute("INSERT INTO like_case_insensitive_test " |
944 | @@ -318,35 +318,35 @@ | |||
945 | 318 | 318 | ||
946 | 319 | def test_case_default_like(self): | 319 | def test_case_default_like(self): |
947 | 320 | 320 | ||
949 | 321 | like = Like(SQLRaw("description"), u"%hullah%") | 321 | like = Like(SQLRaw("description"), "%hullah%") |
950 | 322 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) | 322 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) |
951 | 323 | result = self.connection.execute(expr) | 323 | result = self.connection.execute(expr) |
952 | 324 | self.assertEqual(result.get_all(), [(1,)]) | 324 | self.assertEqual(result.get_all(), [(1,)]) |
953 | 325 | 325 | ||
955 | 326 | like = Like(SQLRaw("description"), u"%HULLAH%") | 326 | like = Like(SQLRaw("description"), "%HULLAH%") |
956 | 327 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) | 327 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) |
957 | 328 | result = self.connection.execute(expr) | 328 | result = self.connection.execute(expr) |
958 | 329 | self.assertEqual(result.get_all(), [(2,)]) | 329 | self.assertEqual(result.get_all(), [(2,)]) |
959 | 330 | 330 | ||
960 | 331 | def test_case_sensitive_like(self): | 331 | def test_case_sensitive_like(self): |
961 | 332 | 332 | ||
963 | 333 | like = Like(SQLRaw("description"), u"%hullah%", case_sensitive=True) | 333 | like = Like(SQLRaw("description"), "%hullah%", case_sensitive=True) |
964 | 334 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) | 334 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) |
965 | 335 | result = self.connection.execute(expr) | 335 | result = self.connection.execute(expr) |
966 | 336 | self.assertEqual(result.get_all(), [(1,)]) | 336 | self.assertEqual(result.get_all(), [(1,)]) |
967 | 337 | 337 | ||
969 | 338 | like = Like(SQLRaw("description"), u"%HULLAH%", case_sensitive=True) | 338 | like = Like(SQLRaw("description"), "%HULLAH%", case_sensitive=True) |
970 | 339 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) | 339 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) |
971 | 340 | result = self.connection.execute(expr) | 340 | result = self.connection.execute(expr) |
972 | 341 | self.assertEqual(result.get_all(), [(2,)]) | 341 | self.assertEqual(result.get_all(), [(2,)]) |
973 | 342 | 342 | ||
974 | 343 | def test_case_insensitive_like(self): | 343 | def test_case_insensitive_like(self): |
975 | 344 | 344 | ||
977 | 345 | like = Like(SQLRaw("description"), u"%hullah%", case_sensitive=False) | 345 | like = Like(SQLRaw("description"), "%hullah%", case_sensitive=False) |
978 | 346 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) | 346 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) |
979 | 347 | result = self.connection.execute(expr) | 347 | result = self.connection.execute(expr) |
980 | 348 | self.assertEqual(result.get_all(), [(1,), (2,)]) | 348 | self.assertEqual(result.get_all(), [(1,), (2,)]) |
982 | 349 | like = Like(SQLRaw("description"), u"%HULLAH%", case_sensitive=False) | 349 | like = Like(SQLRaw("description"), "%HULLAH%", case_sensitive=False) |
983 | 350 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) | 350 | expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"]) |
984 | 351 | result = self.connection.execute(expr) | 351 | result = self.connection.execute(expr) |
985 | 352 | self.assertEqual(result.get_all(), [(1,), (2,)]) | 352 | self.assertEqual(result.get_all(), [(1,), (2,)]) |
986 | @@ -361,7 +361,7 @@ | |||
987 | 361 | self.assertEqual(result.get_one(), (None,)) | 361 | self.assertEqual(result.get_one(), (None,)) |
988 | 362 | 362 | ||
989 | 363 | def test_compile_table_with_schema(self): | 363 | def test_compile_table_with_schema(self): |
991 | 364 | class Foo(object): | 364 | class Foo: |
992 | 365 | __storm_table__ = "my schema.my table" | 365 | __storm_table__ = "my schema.my table" |
993 | 366 | id = Int("my.column", primary=True) | 366 | id = Int("my.column", primary=True) |
994 | 367 | self.assertEqual(compile(Select(Foo.id)), | 367 | self.assertEqual(compile(Select(Foo.id)), |
995 | @@ -371,7 +371,7 @@ | |||
996 | 371 | def test_compile_case(self): | 371 | def test_compile_case(self): |
997 | 372 | """The Case expr is compiled in a Postgres' CASE expression.""" | 372 | """The Case expr is compiled in a Postgres' CASE expression.""" |
998 | 373 | cases = [ | 373 | cases = [ |
1000 | 374 | (Column("foo") > 3, u"big"), (Column("bar") == None, 4)] | 374 | (Column("foo") > 3, "big"), (Column("bar") == None, 4)] |
1001 | 375 | state = State() | 375 | state = State() |
1002 | 376 | statement = compile(Case(cases), state) | 376 | statement = compile(Case(cases), state) |
1003 | 377 | self.assertEqual( | 377 | self.assertEqual( |
1004 | @@ -385,7 +385,7 @@ | |||
1005 | 385 | If a default is provided, the resulting CASE expression includes | 385 | If a default is provided, the resulting CASE expression includes |
1006 | 386 | an ELSE clause. | 386 | an ELSE clause. |
1007 | 387 | """ | 387 | """ |
1009 | 388 | cases = [(Column("foo") > 3, u"big")] | 388 | cases = [(Column("foo") > 3, "big")] |
1010 | 389 | state = State() | 389 | state = State() |
1011 | 390 | statement = compile(Case(cases, default=9), state) | 390 | statement = compile(Case(cases, default=9), state) |
1012 | 391 | self.assertEqual( | 391 | self.assertEqual( |
1013 | @@ -398,7 +398,7 @@ | |||
1014 | 398 | If an expression is provided, the resulting CASE expression uses the | 398 | If an expression is provided, the resulting CASE expression uses the |
1015 | 399 | simple syntax. | 399 | simple syntax. |
1016 | 400 | """ | 400 | """ |
1018 | 401 | cases = [(1, u"one"), (2, u"two")] | 401 | cases = [(1, "one"), (2, "two")] |
1019 | 402 | state = State() | 402 | state = State() |
1020 | 403 | statement = compile(Case(cases, expression=Column("foo")), state) | 403 | statement = compile(Case(cases, expression=Column("foo")), state) |
1021 | 404 | self.assertEqual( | 404 | self.assertEqual( |
1022 | @@ -554,7 +554,7 @@ | |||
1023 | 554 | 554 | ||
1024 | 555 | result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL") | 555 | result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL") |
1025 | 556 | # It matches read committed in Postgres internel | 556 | # It matches read committed in Postgres internel |
1027 | 557 | self.assertEqual(result.get_one()[0], u"read committed") | 557 | self.assertEqual(result.get_one()[0], "read committed") |
1028 | 558 | 558 | ||
1029 | 559 | connection.execute("INSERT INTO bin_test VALUES (1, 'foo')") | 559 | connection.execute("INSERT INTO bin_test VALUES (1, 'foo')") |
1030 | 560 | 560 | ||
1031 | @@ -571,7 +571,7 @@ | |||
1032 | 571 | self.addCleanup(connection.close) | 571 | self.addCleanup(connection.close) |
1033 | 572 | 572 | ||
1034 | 573 | result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL") | 573 | result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL") |
1036 | 574 | self.assertEqual(result.get_one()[0], u"read committed") | 574 | self.assertEqual(result.get_one()[0], "read committed") |
1037 | 575 | 575 | ||
1038 | 576 | connection.execute("INSERT INTO bin_test VALUES (1, 'foo')") | 576 | connection.execute("INSERT INTO bin_test VALUES (1, 'foo')") |
1039 | 577 | 577 | ||
1040 | @@ -600,7 +600,7 @@ | |||
1041 | 600 | self.addCleanup(connection.close) | 600 | self.addCleanup(connection.close) |
1042 | 601 | 601 | ||
1043 | 602 | result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL") | 602 | result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL") |
1045 | 603 | self.assertEqual(result.get_one()[0], u"serializable") | 603 | self.assertEqual(result.get_one()[0], "serializable") |
1046 | 604 | 604 | ||
1047 | 605 | # Start a transaction | 605 | # Start a transaction |
1048 | 606 | result = connection.execute("SELECT 1") | 606 | result = connection.execute("SELECT 1") |
1049 | @@ -623,9 +623,9 @@ | |||
1050 | 623 | import psycopg2 | 623 | import psycopg2 |
1051 | 624 | psycopg2_version = psycopg2.__version__.split(None, 1)[0] | 624 | psycopg2_version = psycopg2.__version__.split(None, 1)[0] |
1052 | 625 | if psycopg2_version < "2.4.2": | 625 | if psycopg2_version < "2.4.2": |
1054 | 626 | self.assertEqual(result.get_one()[0], u"serializable") | 626 | self.assertEqual(result.get_one()[0], "serializable") |
1055 | 627 | else: | 627 | else: |
1057 | 628 | self.assertEqual(result.get_one()[0], u"repeatable read") | 628 | self.assertEqual(result.get_one()[0], "repeatable read") |
1058 | 629 | 629 | ||
1059 | 630 | def test_unknown_serialization(self): | 630 | def test_unknown_serialization(self): |
1060 | 631 | self.assertRaises(ValueError, create_database, | 631 | self.assertRaises(ValueError, create_database, |
1061 | @@ -661,8 +661,8 @@ | |||
1062 | 661 | def test_json_element(self): | 661 | def test_json_element(self): |
1063 | 662 | "JSONElement returns an element from a json field." | 662 | "JSONElement returns an element from a json field." |
1064 | 663 | connection = self.database.connect() | 663 | connection = self.database.connect() |
1067 | 664 | json_value = Cast(u'{"a": 1}', "json") | 664 | json_value = Cast('{"a": 1}', "json") |
1068 | 665 | expr = JSONElement(json_value, u"a") | 665 | expr = JSONElement(json_value, "a") |
1069 | 666 | # Need to cast as text since newer psycopg versions decode JSON | 666 | # Need to cast as text since newer psycopg versions decode JSON |
1070 | 667 | # automatically. | 667 | # automatically. |
1071 | 668 | result = connection.execute(Select(Cast(expr, "text"))) | 668 | result = connection.execute(Select(Cast(expr, "text"))) |
1072 | @@ -673,8 +673,8 @@ | |||
1073 | 673 | def test_json_text_element(self): | 673 | def test_json_text_element(self): |
1074 | 674 | "JSONTextElement returns an element from a json field as text." | 674 | "JSONTextElement returns an element from a json field as text." |
1075 | 675 | connection = self.database.connect() | 675 | connection = self.database.connect() |
1078 | 676 | json_value = Cast(u'{"a": 1}', "json") | 676 | json_value = Cast('{"a": 1}', "json") |
1079 | 677 | expr = JSONTextElement(json_value, u"a") | 677 | expr = JSONTextElement(json_value, "a") |
1080 | 678 | result = connection.execute(Select(expr)) | 678 | result = connection.execute(Select(expr)) |
1081 | 679 | self.assertEqual("1", result.get_one()[0]) | 679 | self.assertEqual("1", result.get_one()[0]) |
1082 | 680 | result = connection.execute(Select(Func("pg_typeof", expr))) | 680 | result = connection.execute(Select(Func("pg_typeof", expr))) |
1083 | @@ -683,7 +683,7 @@ | |||
1084 | 683 | def test_json_property(self): | 683 | def test_json_property(self): |
1085 | 684 | """The JSON property is encoded as JSON""" | 684 | """The JSON property is encoded as JSON""" |
1086 | 685 | 685 | ||
1088 | 686 | class TestModel(object): | 686 | class TestModel: |
1089 | 687 | __storm_table__ = "json_test" | 687 | __storm_table__ = "json_test" |
1090 | 688 | 688 | ||
1091 | 689 | id = Int(primary=True) | 689 | id = Int(primary=True) |
1092 | @@ -747,7 +747,7 @@ | |||
1093 | 747 | if uri.host.startswith("/"): | 747 | if uri.host.startswith("/"): |
1094 | 748 | return create_proxy_and_uri(uri)[0] | 748 | return create_proxy_and_uri(uri)[0] |
1095 | 749 | else: | 749 | else: |
1097 | 750 | return super(PostgresDisconnectionTest, self).create_proxy(uri) | 750 | return super().create_proxy(uri) |
1098 | 751 | 751 | ||
1099 | 752 | def test_rollback_swallows_InterfaceError(self): | 752 | def test_rollback_swallows_InterfaceError(self): |
1100 | 753 | """Test that InterfaceErrors get caught on rollback(). | 753 | """Test that InterfaceErrors get caught on rollback(). |
1101 | @@ -765,18 +765,17 @@ | |||
1102 | 765 | self.fail('Exception should have been swallowed: %s' % repr(exc)) | 765 | self.fail('Exception should have been swallowed: %s' % repr(exc)) |
1103 | 766 | 766 | ||
1104 | 767 | 767 | ||
1106 | 768 | class PostgresDisconnectionTestWithoutProxyBase(object): | 768 | class PostgresDisconnectionTestWithoutProxyBase: |
1107 | 769 | # DatabaseDisconnectionTest uses a socket proxy to simulate broken | 769 | # DatabaseDisconnectionTest uses a socket proxy to simulate broken |
1108 | 770 | # connections. This class tests some other causes of disconnection. | 770 | # connections. This class tests some other causes of disconnection. |
1109 | 771 | 771 | ||
1110 | 772 | database_uri = None | 772 | database_uri = None |
1111 | 773 | 773 | ||
1112 | 774 | def is_supported(self): | 774 | def is_supported(self): |
1115 | 775 | return bool(self.database_uri) and super( | 775 | return bool(self.database_uri) and super().is_supported() |
1114 | 776 | PostgresDisconnectionTestWithoutProxyBase, self).is_supported() | ||
1116 | 777 | 776 | ||
1117 | 778 | def setUp(self): | 777 | def setUp(self): |
1119 | 779 | super(PostgresDisconnectionTestWithoutProxyBase, self).setUp() | 778 | super().setUp() |
1120 | 780 | self.database = create_database(self.database_uri) | 779 | self.database = create_database(self.database_uri) |
1121 | 781 | 780 | ||
1122 | 782 | def test_terminated_backend(self): | 781 | def test_terminated_backend(self): |
1123 | @@ -816,14 +815,14 @@ | |||
1124 | 816 | database_uri = os.environ.get("STORM_POSTGRES_HOST_URI") | 815 | database_uri = os.environ.get("STORM_POSTGRES_HOST_URI") |
1125 | 817 | 816 | ||
1126 | 818 | def setUp(self): | 817 | def setUp(self): |
1128 | 819 | super(PostgresDisconnectionTestWithoutProxyTCPSockets, self).setUp() | 818 | super().setUp() |
1129 | 820 | if self.database.get_uri().host.startswith("/"): | 819 | if self.database.get_uri().host.startswith("/"): |
1130 | 821 | proxy, proxy_uri = create_proxy_and_uri(self.database.get_uri()) | 820 | proxy, proxy_uri = create_proxy_and_uri(self.database.get_uri()) |
1131 | 822 | self.addCleanup(proxy.close) | 821 | self.addCleanup(proxy.close) |
1132 | 823 | self.database = create_database(proxy_uri) | 822 | self.database = create_database(proxy_uri) |
1133 | 824 | 823 | ||
1134 | 825 | 824 | ||
1136 | 826 | class PostgresDisconnectionTestWithPGBouncerBase(object): | 825 | class PostgresDisconnectionTestWithPGBouncerBase: |
1137 | 827 | # Connecting via pgbouncer <http://pgfoundry.org/projects/pgbouncer> | 826 | # Connecting via pgbouncer <http://pgfoundry.org/projects/pgbouncer> |
1138 | 828 | # introduces new possible causes of disconnections. | 827 | # introduces new possible causes of disconnections. |
1139 | 829 | 828 | ||
1140 | @@ -833,7 +832,7 @@ | |||
1141 | 833 | bool(os.environ.get("STORM_POSTGRES_HOST_URI"))) | 832 | bool(os.environ.get("STORM_POSTGRES_HOST_URI"))) |
1142 | 834 | 833 | ||
1143 | 835 | def setUp(self): | 834 | def setUp(self): |
1145 | 836 | super(PostgresDisconnectionTestWithPGBouncerBase, self).setUp() | 835 | super().setUp() |
1146 | 837 | database_uri = URI(os.environ["STORM_POSTGRES_HOST_URI"]) | 836 | database_uri = URI(os.environ["STORM_POSTGRES_HOST_URI"]) |
1147 | 838 | if database_uri.host.startswith("/"): | 837 | if database_uri.host.startswith("/"): |
1148 | 839 | proxy, database_uri = create_proxy_and_uri(database_uri) | 838 | proxy, database_uri = create_proxy_and_uri(database_uri) |
1149 | @@ -889,7 +888,7 @@ | |||
1150 | 889 | return bool(os.environ.get("STORM_POSTGRES_URI")) | 888 | return bool(os.environ.get("STORM_POSTGRES_URI")) |
1151 | 890 | 889 | ||
1152 | 891 | def setUp(self): | 890 | def setUp(self): |
1154 | 892 | super(PostgresTimeoutTracerTest, self).setUp() | 891 | super().setUp() |
1155 | 893 | self.database = create_database(os.environ["STORM_POSTGRES_URI"]) | 892 | self.database = create_database(os.environ["STORM_POSTGRES_URI"]) |
1156 | 894 | self.connection = self.database.connect() | 893 | self.connection = self.database.connect() |
1157 | 895 | install_tracer(self.tracer) | 894 | install_tracer(self.tracer) |
1158 | @@ -898,7 +897,7 @@ | |||
1159 | 898 | 897 | ||
1160 | 899 | def tearDown(self): | 898 | def tearDown(self): |
1161 | 900 | self.connection.close() | 899 | self.connection.close() |
1163 | 901 | super(PostgresTimeoutTracerTest, self).tearDown() | 900 | super().tearDown() |
1164 | 902 | 901 | ||
1165 | 903 | def test_set_statement_timeout(self): | 902 | def test_set_statement_timeout(self): |
1166 | 904 | result = self.connection.execute("SHOW statement_timeout") | 903 | result = self.connection.execute("SHOW statement_timeout") |
1167 | 905 | 904 | ||
1168 | === modified file 'storm/tests/databases/proxy.py' | |||
1169 | --- storm/tests/databases/proxy.py 2024-03-04 10:59:55 +0000 | |||
1170 | +++ storm/tests/databases/proxy.py 2024-03-13 16:26:38 +0000 | |||
1171 | @@ -1,4 +1,3 @@ | |||
1172 | 1 | # -*- encoding: utf-8 -*- | ||
1173 | 2 | # | 1 | # |
1174 | 3 | # Copyright (c) 2006, 2007 Canonical | 2 | # Copyright (c) 2006, 2007 Canonical |
1175 | 4 | # | 3 | # |
1176 | @@ -59,7 +58,7 @@ | |||
1177 | 59 | chunk = os.read(self.request.fileno(), 1024) | 58 | chunk = os.read(self.request.fileno(), 1024) |
1178 | 60 | try: | 59 | try: |
1179 | 61 | dst.send(chunk) | 60 | dst.send(chunk) |
1181 | 62 | except socket.error as e: | 61 | except OSError as e: |
1182 | 63 | if e.errno == errno.EPIPE: | 62 | if e.errno == errno.EPIPE: |
1183 | 64 | return | 63 | return |
1184 | 65 | raise | 64 | raise |
1185 | 66 | 65 | ||
1186 | === modified file 'storm/tests/databases/sqlite.py' | |||
1187 | --- storm/tests/databases/sqlite.py 2024-03-04 10:59:55 +0000 | |||
1188 | +++ storm/tests/databases/sqlite.py 2024-03-13 16:26:38 +0000 | |||
1189 | @@ -184,9 +184,9 @@ | |||
1190 | 184 | [(1,), (2,)]) | 184 | [(1,), (2,)]) |
1191 | 185 | 185 | ||
1192 | 186 | def test_journal(self): | 186 | def test_journal(self): |
1196 | 187 | journal_values = {"DELETE": u'delete', "TRUNCATE": u'truncate', | 187 | journal_values = {"DELETE": 'delete', "TRUNCATE": 'truncate', |
1197 | 188 | "PERSIST": u'persist', "MEMORY": u'memory', | 188 | "PERSIST": 'persist', "MEMORY": 'memory', |
1198 | 189 | "WAL": u'wal', "OFF": u'off'} | 189 | "WAL": 'wal', "OFF": 'off'} |
1199 | 190 | for value in journal_values: | 190 | for value in journal_values: |
1200 | 191 | database = SQLite(URI("sqlite:%s?journal_mode=%s" % | 191 | database = SQLite(URI("sqlite:%s?journal_mode=%s" % |
1201 | 192 | (self.get_path(), value))) | 192 | (self.get_path(), value))) |
1202 | @@ -196,9 +196,9 @@ | |||
1203 | 196 | journal_values[value]) | 196 | journal_values[value]) |
1204 | 197 | 197 | ||
1205 | 198 | def test_journal_persistency_to_rollback(self): | 198 | def test_journal_persistency_to_rollback(self): |
1209 | 199 | journal_values = {"DELETE": u'delete', "TRUNCATE": u'truncate', | 199 | journal_values = {"DELETE": 'delete', "TRUNCATE": 'truncate', |
1210 | 200 | "PERSIST": u'persist', "MEMORY": u'memory', | 200 | "PERSIST": 'persist', "MEMORY": 'memory', |
1211 | 201 | "WAL": u'wal', "OFF": u'off'} | 201 | "WAL": 'wal', "OFF": 'off'} |
1212 | 202 | for value in journal_values: | 202 | for value in journal_values: |
1213 | 203 | database = SQLite(URI("sqlite:%s?journal_mode=%s" % | 203 | database = SQLite(URI("sqlite:%s?journal_mode=%s" % |
1214 | 204 | (self.get_path(), value))) | 204 | (self.get_path(), value))) |
1215 | 205 | 205 | ||
1216 | === modified file 'storm/tests/event.py' | |||
1217 | --- storm/tests/event.py 2024-03-04 16:31:48 +0000 | |||
1218 | +++ storm/tests/event.py 2024-03-13 16:26:38 +0000 | |||
1219 | @@ -22,7 +22,7 @@ | |||
1220 | 22 | from storm.tests.helper import TestHelper | 22 | from storm.tests.helper import TestHelper |
1221 | 23 | 23 | ||
1222 | 24 | 24 | ||
1224 | 25 | class Marker(object): | 25 | class Marker: |
1225 | 26 | def __eq__(self, other): | 26 | def __eq__(self, other): |
1226 | 27 | return self is other | 27 | return self is other |
1227 | 28 | 28 | ||
1228 | 29 | 29 | ||
1229 | === modified file 'storm/tests/expr.py' | |||
1230 | --- storm/tests/expr.py 2024-03-04 10:59:55 +0000 | |||
1231 | +++ storm/tests/expr.py 2024-03-13 16:26:38 +0000 | |||
1232 | @@ -188,38 +188,38 @@ | |||
1233 | 188 | expr = Func1() | 188 | expr = Func1() |
1234 | 189 | self.assertRaises(ExprError, expr.startswith, b"not a unicode string") | 189 | self.assertRaises(ExprError, expr.startswith, b"not a unicode string") |
1235 | 190 | 190 | ||
1237 | 191 | like_expr = expr.startswith(u"abc!!_%") | 191 | like_expr = expr.startswith("abc!!_%") |
1238 | 192 | self.assertTrue(isinstance(like_expr, Like)) | 192 | self.assertTrue(isinstance(like_expr, Like)) |
1239 | 193 | self.assertIs(like_expr.expr1, expr) | 193 | self.assertIs(like_expr.expr1, expr) |
1242 | 194 | self.assertEqual(like_expr.expr2, u"abc!!!!!_!%%") | 194 | self.assertEqual(like_expr.expr2, "abc!!!!!_!%%") |
1243 | 195 | self.assertEqual(like_expr.escape, u"!") | 195 | self.assertEqual(like_expr.escape, "!") |
1244 | 196 | 196 | ||
1245 | 197 | def test_startswith_case(self): | 197 | def test_startswith_case(self): |
1246 | 198 | expr = Func1() | 198 | expr = Func1() |
1248 | 199 | like_expr = expr.startswith(u"abc!!_%") | 199 | like_expr = expr.startswith("abc!!_%") |
1249 | 200 | self.assertIsNone(like_expr.case_sensitive) | 200 | self.assertIsNone(like_expr.case_sensitive) |
1251 | 201 | like_expr = expr.startswith(u"abc!!_%", case_sensitive=True) | 201 | like_expr = expr.startswith("abc!!_%", case_sensitive=True) |
1252 | 202 | self.assertIs(True, like_expr.case_sensitive) | 202 | self.assertIs(True, like_expr.case_sensitive) |
1254 | 203 | like_expr = expr.startswith(u"abc!!_%", case_sensitive=False) | 203 | like_expr = expr.startswith("abc!!_%", case_sensitive=False) |
1255 | 204 | self.assertIs(False, like_expr.case_sensitive) | 204 | self.assertIs(False, like_expr.case_sensitive) |
1256 | 205 | 205 | ||
1257 | 206 | def test_endswith(self): | 206 | def test_endswith(self): |
1258 | 207 | expr = Func1() | 207 | expr = Func1() |
1259 | 208 | self.assertRaises(ExprError, expr.startswith, b"not a unicode string") | 208 | self.assertRaises(ExprError, expr.startswith, b"not a unicode string") |
1260 | 209 | 209 | ||
1262 | 210 | like_expr = expr.endswith(u"abc!!_%") | 210 | like_expr = expr.endswith("abc!!_%") |
1263 | 211 | self.assertTrue(isinstance(like_expr, Like)) | 211 | self.assertTrue(isinstance(like_expr, Like)) |
1264 | 212 | self.assertIs(like_expr.expr1, expr) | 212 | self.assertIs(like_expr.expr1, expr) |
1267 | 213 | self.assertEqual(like_expr.expr2, u"%abc!!!!!_!%") | 213 | self.assertEqual(like_expr.expr2, "%abc!!!!!_!%") |
1268 | 214 | self.assertEqual(like_expr.escape, u"!") | 214 | self.assertEqual(like_expr.escape, "!") |
1269 | 215 | 215 | ||
1270 | 216 | def test_endswith_case(self): | 216 | def test_endswith_case(self): |
1271 | 217 | expr = Func1() | 217 | expr = Func1() |
1273 | 218 | like_expr = expr.endswith(u"abc!!_%") | 218 | like_expr = expr.endswith("abc!!_%") |
1274 | 219 | self.assertIsNone(like_expr.case_sensitive) | 219 | self.assertIsNone(like_expr.case_sensitive) |
1276 | 220 | like_expr = expr.endswith(u"abc!!_%", case_sensitive=True) | 220 | like_expr = expr.endswith("abc!!_%", case_sensitive=True) |
1277 | 221 | self.assertIs(True, like_expr.case_sensitive) | 221 | self.assertIs(True, like_expr.case_sensitive) |
1279 | 222 | like_expr = expr.endswith(u"abc!!_%", case_sensitive=False) | 222 | like_expr = expr.endswith("abc!!_%", case_sensitive=False) |
1280 | 223 | self.assertIs(False, like_expr.case_sensitive) | 223 | self.assertIs(False, like_expr.case_sensitive) |
1281 | 224 | 224 | ||
1282 | 225 | def test_contains_string(self): | 225 | def test_contains_string(self): |
1283 | @@ -227,19 +227,19 @@ | |||
1284 | 227 | self.assertRaises( | 227 | self.assertRaises( |
1285 | 228 | ExprError, expr.contains_string, b"not a unicode string") | 228 | ExprError, expr.contains_string, b"not a unicode string") |
1286 | 229 | 229 | ||
1288 | 230 | like_expr = expr.contains_string(u"abc!!_%") | 230 | like_expr = expr.contains_string("abc!!_%") |
1289 | 231 | self.assertTrue(isinstance(like_expr, Like)) | 231 | self.assertTrue(isinstance(like_expr, Like)) |
1290 | 232 | self.assertIs(like_expr.expr1, expr) | 232 | self.assertIs(like_expr.expr1, expr) |
1293 | 233 | self.assertEqual(like_expr.expr2, u"%abc!!!!!_!%%") | 233 | self.assertEqual(like_expr.expr2, "%abc!!!!!_!%%") |
1294 | 234 | self.assertEqual(like_expr.escape, u"!") | 234 | self.assertEqual(like_expr.escape, "!") |
1295 | 235 | 235 | ||
1296 | 236 | def test_contains_string_case(self): | 236 | def test_contains_string_case(self): |
1297 | 237 | expr = Func1() | 237 | expr = Func1() |
1299 | 238 | like_expr = expr.contains_string(u"abc!!_%") | 238 | like_expr = expr.contains_string("abc!!_%") |
1300 | 239 | self.assertIsNone(like_expr.case_sensitive) | 239 | self.assertIsNone(like_expr.case_sensitive) |
1302 | 240 | like_expr = expr.contains_string(u"abc!!_%", case_sensitive=True) | 240 | like_expr = expr.contains_string("abc!!_%", case_sensitive=True) |
1303 | 241 | self.assertIs(True, like_expr.case_sensitive) | 241 | self.assertIs(True, like_expr.case_sensitive) |
1305 | 242 | like_expr = expr.contains_string(u"abc!!_%", case_sensitive=False) | 242 | like_expr = expr.contains_string("abc!!_%", case_sensitive=False) |
1306 | 243 | self.assertIs(False, like_expr.case_sensitive) | 243 | self.assertIs(False, like_expr.case_sensitive) |
1307 | 244 | 244 | ||
1308 | 245 | def test_is(self): | 245 | def test_is(self): |
1309 | @@ -513,7 +513,7 @@ | |||
1310 | 513 | self.assertEqual(statement, "func1(None)") | 513 | self.assertEqual(statement, "func1(None)") |
1311 | 514 | 514 | ||
1312 | 515 | def test_customize_inheritance(self): | 515 | def test_customize_inheritance(self): |
1314 | 516 | class C(object): pass | 516 | class C: pass |
1315 | 517 | compile_parent = Compile() | 517 | compile_parent = Compile() |
1316 | 518 | compile_child = compile_parent.create_child() | 518 | compile_child = compile_parent.create_child() |
1317 | 519 | 519 | ||
1318 | @@ -610,9 +610,9 @@ | |||
1319 | 610 | 610 | ||
1320 | 611 | def test_unicode(self): | 611 | def test_unicode(self): |
1321 | 612 | state = State() | 612 | state = State() |
1323 | 613 | statement = compile(u"str", state) | 613 | statement = compile("str", state) |
1324 | 614 | self.assertEqual(statement, "?") | 614 | self.assertEqual(statement, "?") |
1326 | 615 | self.assertVariablesEqual(state.parameters, [UnicodeVariable(u"str")]) | 615 | self.assertVariablesEqual(state.parameters, [UnicodeVariable("str")]) |
1327 | 616 | 616 | ||
1328 | 617 | def test_int(self): | 617 | def test_int(self): |
1329 | 618 | state = State() | 618 | state = State() |
1330 | @@ -812,8 +812,8 @@ | |||
1331 | 812 | self.assertEqual(state.parameters, []) | 812 | self.assertEqual(state.parameters, []) |
1332 | 813 | 813 | ||
1333 | 814 | def test_select_with_unicode(self): | 814 | def test_select_with_unicode(self): |
1336 | 815 | expr = Select(column1, u"1 = 2", table1, order_by=u"column1", | 815 | expr = Select(column1, "1 = 2", table1, order_by="column1", |
1337 | 816 | group_by=[u"column2"]) | 816 | group_by=["column2"]) |
1338 | 817 | state = State() | 817 | state = State() |
1339 | 818 | statement = compile(expr, state) | 818 | statement = compile(expr, state) |
1340 | 819 | self.assertEqual(statement, 'SELECT column1 FROM "table 1" ' | 819 | self.assertEqual(statement, 'SELECT column1 FROM "table 1" ' |
1341 | @@ -822,8 +822,8 @@ | |||
1342 | 822 | self.assertEqual(state.parameters, []) | 822 | self.assertEqual(state.parameters, []) |
1343 | 823 | 823 | ||
1344 | 824 | def test_select_having(self): | 824 | def test_select_having(self): |
1347 | 825 | expr = Select(column1, tables=table1, order_by=u"column1", | 825 | expr = Select(column1, tables=table1, order_by="column1", |
1348 | 826 | group_by=[u"column2"], having=u"1 = 2") | 826 | group_by=["column2"], having="1 = 2") |
1349 | 827 | state = State() | 827 | state = State() |
1350 | 828 | statement = compile(expr, state) | 828 | statement = compile(expr, state) |
1351 | 829 | self.assertEqual(statement, 'SELECT column1 FROM "table 1" ' | 829 | self.assertEqual(statement, 'SELECT column1 FROM "table 1" ' |
1352 | @@ -2244,7 +2244,7 @@ | |||
1353 | 2244 | self.assertEqual(py_expr, "b'str'") | 2244 | self.assertEqual(py_expr, "b'str'") |
1354 | 2245 | 2245 | ||
1355 | 2246 | def test_unicode(self): | 2246 | def test_unicode(self): |
1357 | 2247 | py_expr = compile_python(u"str") | 2247 | py_expr = compile_python("str") |
1358 | 2248 | self.assertEqual(py_expr, "'str'") | 2248 | self.assertEqual(py_expr, "'str'") |
1359 | 2249 | 2249 | ||
1360 | 2250 | def test_int(self): | 2250 | def test_int(self): |
1361 | @@ -2483,7 +2483,7 @@ | |||
1362 | 2483 | def test_match_bad_repr(self): | 2483 | def test_match_bad_repr(self): |
1363 | 2484 | """The get_matcher() works for expressions containing values | 2484 | """The get_matcher() works for expressions containing values |
1364 | 2485 | whose repr is not valid Python syntax.""" | 2485 | whose repr is not valid Python syntax.""" |
1366 | 2486 | class BadRepr(object): | 2486 | class BadRepr: |
1367 | 2487 | def __repr__(self): | 2487 | def __repr__(self): |
1368 | 2488 | return "$Not a valid Python expression$" | 2488 | return "$Not a valid Python expression$" |
1369 | 2489 | 2489 | ||
1370 | 2490 | 2490 | ||
1371 | === modified file 'storm/tests/helper.py' | |||
1372 | --- storm/tests/helper.py 2024-03-04 10:59:55 +0000 | |||
1373 | +++ storm/tests/helper.py 2024-03-13 16:26:38 +0000 | |||
1374 | @@ -38,7 +38,7 @@ | |||
1375 | 38 | return True | 38 | return True |
1376 | 39 | 39 | ||
1377 | 40 | def setUp(self): | 40 | def setUp(self): |
1379 | 41 | super(TestHelper, self).setUp() | 41 | super().setUp() |
1380 | 42 | self._helper_instances = [] | 42 | self._helper_instances = [] |
1381 | 43 | for helper_factory in self.helpers: | 43 | for helper_factory in self.helpers: |
1382 | 44 | helper = helper_factory() | 44 | helper = helper_factory() |
1383 | @@ -48,7 +48,7 @@ | |||
1384 | 48 | def tearDown(self): | 48 | def tearDown(self): |
1385 | 49 | for helper in reversed(self._helper_instances): | 49 | for helper in reversed(self._helper_instances): |
1386 | 50 | helper.tear_down(self) | 50 | helper.tear_down(self) |
1388 | 51 | super(TestHelper, self).tearDown() | 51 | super().tearDown() |
1389 | 52 | 52 | ||
1390 | 53 | @property | 53 | @property |
1391 | 54 | def _testMethod(self): | 54 | def _testMethod(self): |
1392 | @@ -61,7 +61,7 @@ | |||
1393 | 61 | result.startTest(self) | 61 | result.startTest(self) |
1394 | 62 | result.addSkip(self, "Test not supported") | 62 | result.addSkip(self, "Test not supported") |
1395 | 63 | return | 63 | return |
1397 | 64 | super(TestHelper, self).run(result) | 64 | super().run(result) |
1398 | 65 | 65 | ||
1399 | 66 | def assertVariablesEqual(self, checked, expected): | 66 | def assertVariablesEqual(self, checked, expected): |
1400 | 67 | self.assertEqual(len(checked), len(expected)) | 67 | self.assertEqual(len(checked), len(expected)) |
1401 | @@ -70,7 +70,7 @@ | |||
1402 | 70 | self.assertEqual(check.get(), expect.get()) | 70 | self.assertEqual(check.get(), expect.get()) |
1403 | 71 | 71 | ||
1404 | 72 | 72 | ||
1406 | 73 | class MakePath(object): | 73 | class MakePath: |
1407 | 74 | 74 | ||
1408 | 75 | def set_up(self, test_case): | 75 | def set_up(self, test_case): |
1409 | 76 | self.dirname = tempfile.mkdtemp() | 76 | self.dirname = tempfile.mkdtemp() |
1410 | @@ -101,7 +101,7 @@ | |||
1411 | 101 | return path | 101 | return path |
1412 | 102 | 102 | ||
1413 | 103 | 103 | ||
1415 | 104 | class LogKeeper(object): | 104 | class LogKeeper: |
1416 | 105 | """Record logging information. | 105 | """Record logging information. |
1417 | 106 | 106 | ||
1418 | 107 | Puts a 'logfile' attribute on your test case, which is a StringIO | 107 | Puts a 'logfile' attribute on your test case, which is a StringIO |
1419 | 108 | 108 | ||
1420 | === modified file 'storm/tests/info.py' | |||
1421 | --- storm/tests/info.py 2024-03-04 10:59:55 +0000 | |||
1422 | +++ storm/tests/info.py 2024-03-13 16:26:38 +0000 | |||
1423 | @@ -29,7 +29,7 @@ | |||
1424 | 29 | from storm.tests.helper import TestHelper | 29 | from storm.tests.helper import TestHelper |
1425 | 30 | 30 | ||
1426 | 31 | 31 | ||
1428 | 32 | class Wrapper(object): | 32 | class Wrapper: |
1429 | 33 | 33 | ||
1430 | 34 | def __init__(self, obj): | 34 | def __init__(self, obj): |
1431 | 35 | self.obj = obj | 35 | self.obj = obj |
1432 | @@ -42,7 +42,7 @@ | |||
1433 | 42 | 42 | ||
1434 | 43 | def setUp(self): | 43 | def setUp(self): |
1435 | 44 | TestHelper.setUp(self) | 44 | TestHelper.setUp(self) |
1437 | 45 | class Class(object): | 45 | class Class: |
1438 | 46 | __storm_table__ = "table" | 46 | __storm_table__ = "table" |
1439 | 47 | prop1 = Property("column1", primary=True) | 47 | prop1 = Property("column1", primary=True) |
1440 | 48 | self.Class = Class | 48 | self.Class = Class |
1441 | @@ -74,7 +74,7 @@ | |||
1442 | 74 | 74 | ||
1443 | 75 | def setUp(self): | 75 | def setUp(self): |
1444 | 76 | TestHelper.setUp(self) | 76 | TestHelper.setUp(self) |
1446 | 77 | class Class(object): | 77 | class Class: |
1447 | 78 | __storm_table__ = "table" | 78 | __storm_table__ = "table" |
1448 | 79 | prop1 = Property("column1", primary=True) | 79 | prop1 = Property("column1", primary=True) |
1449 | 80 | prop2 = Property("column2") | 80 | prop2 = Property("column2") |
1450 | @@ -82,7 +82,7 @@ | |||
1451 | 82 | self.cls_info = get_cls_info(Class) | 82 | self.cls_info = get_cls_info(Class) |
1452 | 83 | 83 | ||
1453 | 84 | def test_invalid_class(self): | 84 | def test_invalid_class(self): |
1455 | 85 | class Class(object): pass | 85 | class Class: pass |
1456 | 86 | self.assertRaises(ClassInfoError, ClassInfo, Class) | 86 | self.assertRaises(ClassInfoError, ClassInfo, Class) |
1457 | 87 | 87 | ||
1458 | 88 | def test_cls(self): | 88 | def test_cls(self): |
1459 | @@ -110,7 +110,7 @@ | |||
1460 | 110 | self.assertEqual(len(self.cls_info.primary_key), 1) | 110 | self.assertEqual(len(self.cls_info.primary_key), 1) |
1461 | 111 | 111 | ||
1462 | 112 | def test_primary_key_composed(self): | 112 | def test_primary_key_composed(self): |
1464 | 113 | class Class(object): | 113 | class Class: |
1465 | 114 | __storm_table__ = "table" | 114 | __storm_table__ = "table" |
1466 | 115 | prop1 = Property("column1", primary=2) | 115 | prop1 = Property("column1", primary=2) |
1467 | 116 | prop2 = Property("column2", primary=1) | 116 | prop2 = Property("column2", primary=1) |
1468 | @@ -122,7 +122,7 @@ | |||
1469 | 122 | self.assertEqual(len(cls_info.primary_key), 2) | 122 | self.assertEqual(len(cls_info.primary_key), 2) |
1470 | 123 | 123 | ||
1471 | 124 | def test_primary_key_composed_with_attribute(self): | 124 | def test_primary_key_composed_with_attribute(self): |
1473 | 125 | class Class(object): | 125 | class Class: |
1474 | 126 | __storm_table__ = "table" | 126 | __storm_table__ = "table" |
1475 | 127 | __storm_primary__ = "prop2", "prop1" | 127 | __storm_primary__ = "prop2", "prop1" |
1476 | 128 | # Define primary=True to ensure that the attribute | 128 | # Define primary=True to ensure that the attribute |
1477 | @@ -137,21 +137,21 @@ | |||
1478 | 137 | self.assertEqual(len(cls_info.primary_key), 2) | 137 | self.assertEqual(len(cls_info.primary_key), 2) |
1479 | 138 | 138 | ||
1480 | 139 | def test_primary_key_composed_duplicated(self): | 139 | def test_primary_key_composed_duplicated(self): |
1482 | 140 | class Class(object): | 140 | class Class: |
1483 | 141 | __storm_table__ = "table" | 141 | __storm_table__ = "table" |
1484 | 142 | prop1 = Property("column1", primary=True) | 142 | prop1 = Property("column1", primary=True) |
1485 | 143 | prop2 = Property("column2", primary=True) | 143 | prop2 = Property("column2", primary=True) |
1486 | 144 | self.assertRaises(ClassInfoError, ClassInfo, Class) | 144 | self.assertRaises(ClassInfoError, ClassInfo, Class) |
1487 | 145 | 145 | ||
1488 | 146 | def test_primary_key_missing(self): | 146 | def test_primary_key_missing(self): |
1490 | 147 | class Class(object): | 147 | class Class: |
1491 | 148 | __storm_table__ = "table" | 148 | __storm_table__ = "table" |
1492 | 149 | prop1 = Property("column1") | 149 | prop1 = Property("column1") |
1493 | 150 | prop2 = Property("column2") | 150 | prop2 = Property("column2") |
1494 | 151 | self.assertRaises(ClassInfoError, ClassInfo, Class) | 151 | self.assertRaises(ClassInfoError, ClassInfo, Class) |
1495 | 152 | 152 | ||
1496 | 153 | def test_primary_key_attribute_missing(self): | 153 | def test_primary_key_attribute_missing(self): |
1498 | 154 | class Class(object): | 154 | class Class: |
1499 | 155 | __storm_table__ = "table" | 155 | __storm_table__ = "table" |
1500 | 156 | __storm_primary__ = () | 156 | __storm_primary__ = () |
1501 | 157 | prop1 = Property("column1", primary=True) | 157 | prop1 = Property("column1", primary=True) |
1502 | @@ -159,7 +159,7 @@ | |||
1503 | 159 | self.assertRaises(ClassInfoError, ClassInfo, Class) | 159 | self.assertRaises(ClassInfoError, ClassInfo, Class) |
1504 | 160 | 160 | ||
1505 | 161 | def test_primary_key_pos(self): | 161 | def test_primary_key_pos(self): |
1507 | 162 | class Class(object): | 162 | class Class: |
1508 | 163 | __storm_table__ = "table" | 163 | __storm_table__ = "table" |
1509 | 164 | prop1 = Property("column1", primary=2) | 164 | prop1 = Property("column1", primary=2) |
1510 | 165 | prop2 = Property("column2") | 165 | prop2 = Property("column2") |
1511 | @@ -172,7 +172,7 @@ | |||
1512 | 172 | 172 | ||
1513 | 173 | def setUp(self): | 173 | def setUp(self): |
1514 | 174 | TestHelper.setUp(self) | 174 | TestHelper.setUp(self) |
1516 | 175 | class Class(object): | 175 | class Class: |
1517 | 176 | __storm_table__ = "table" | 176 | __storm_table__ = "table" |
1518 | 177 | prop1 = Property("column1", primary=True) | 177 | prop1 = Property("column1", primary=True) |
1519 | 178 | prop2 = Property("column2") | 178 | prop2 = Property("column2") |
1520 | @@ -214,7 +214,7 @@ | |||
1521 | 214 | args = [] | 214 | args = [] |
1522 | 215 | def validator(obj, attr, value): | 215 | def validator(obj, attr, value): |
1523 | 216 | args.append((obj, attr, value)) | 216 | args.append((obj, attr, value)) |
1525 | 217 | class Class(object): | 217 | class Class: |
1526 | 218 | __storm_table__ = "table" | 218 | __storm_table__ = "table" |
1527 | 219 | prop = Property(primary=True, | 219 | prop = Property(primary=True, |
1528 | 220 | variable_kwargs={"validator": validator}) | 220 | variable_kwargs={"validator": validator}) |
1529 | @@ -522,7 +522,7 @@ | |||
1530 | 522 | 522 | ||
1531 | 523 | def setUp(self): | 523 | def setUp(self): |
1532 | 524 | TestHelper.setUp(self) | 524 | TestHelper.setUp(self) |
1534 | 525 | class Class(object): | 525 | class Class: |
1535 | 526 | __storm_table__ = "table" | 526 | __storm_table__ = "table" |
1536 | 527 | prop1 = Property("column1", primary=True) | 527 | prop1 = Property("column1", primary=True) |
1537 | 528 | self.Class = Class | 528 | self.Class = Class |
1538 | @@ -624,10 +624,10 @@ | |||
1539 | 624 | 624 | ||
1540 | 625 | def test_nested_classes(self): | 625 | def test_nested_classes(self): |
1541 | 626 | """Convoluted case checking that the model is right.""" | 626 | """Convoluted case checking that the model is right.""" |
1543 | 627 | class Class1(object): | 627 | class Class1: |
1544 | 628 | __storm_table__ = "class1" | 628 | __storm_table__ = "class1" |
1545 | 629 | id = Property(primary=True) | 629 | id = Property(primary=True) |
1547 | 630 | class Class2(object): | 630 | class Class2: |
1548 | 631 | __storm_table__ = Class1 | 631 | __storm_table__ = Class1 |
1549 | 632 | id = Property(primary=True) | 632 | id = Property(primary=True) |
1550 | 633 | statement = compile(Class2) | 633 | statement = compile(Class2) |
1551 | 634 | 634 | ||
1552 | === modified file 'storm/tests/mocker.py' | |||
1553 | --- storm/tests/mocker.py 2024-03-04 10:59:55 +0000 | |||
1554 | +++ storm/tests/mocker.py 2024-03-13 16:26:38 +0000 | |||
1555 | @@ -35,7 +35,7 @@ | |||
1556 | 35 | # -------------------------------------------------------------------- | 35 | # -------------------------------------------------------------------- |
1557 | 36 | # Helper for chained-style calling. | 36 | # Helper for chained-style calling. |
1558 | 37 | 37 | ||
1560 | 38 | class expect(object): | 38 | class expect: |
1561 | 39 | """This is a simple helper that allows a different call-style. | 39 | """This is a simple helper that allows a different call-style. |
1562 | 40 | 40 | ||
1563 | 41 | With this class one can comfortably do chaining of calls to the | 41 | With this class one can comfortably do chaining of calls to the |
1564 | @@ -136,7 +136,7 @@ | |||
1565 | 136 | self.__cleanup_funcs = [] | 136 | self.__cleanup_funcs = [] |
1566 | 137 | self.__cleanup_paths = [] | 137 | self.__cleanup_paths = [] |
1567 | 138 | 138 | ||
1569 | 139 | super(MockerTestCase, self).__init__(methodName) | 139 | super().__init__(methodName) |
1570 | 140 | 140 | ||
1571 | 141 | def __cleanup(self): | 141 | def __cleanup(self): |
1572 | 142 | for path in self.__cleanup_paths: | 142 | for path in self.__cleanup_paths: |
1573 | @@ -308,13 +308,13 @@ | |||
1574 | 308 | 308 | ||
1575 | 309 | if sys.version_info < (3, 2): | 309 | if sys.version_info < (3, 2): |
1576 | 310 | def assertRaisesRegex(self, *args, **kwargs): | 310 | def assertRaisesRegex(self, *args, **kwargs): |
1578 | 311 | return self.assertRaisesRegexp(*args, **kwargs) | 311 | return self.assertRaisesRegex(*args, **kwargs) |
1579 | 312 | 312 | ||
1580 | 313 | 313 | ||
1581 | 314 | # -------------------------------------------------------------------- | 314 | # -------------------------------------------------------------------- |
1582 | 315 | # Mocker. | 315 | # Mocker. |
1583 | 316 | 316 | ||
1585 | 317 | class classinstancemethod(object): | 317 | class classinstancemethod: |
1586 | 318 | 318 | ||
1587 | 319 | def __init__(self, method): | 319 | def __init__(self, method): |
1588 | 320 | self.method = method | 320 | self.method = method |
1589 | @@ -752,8 +752,7 @@ | |||
1590 | 752 | @param sequence: Sequence of values to be generated. | 752 | @param sequence: Sequence of values to be generated. |
1591 | 753 | """ | 753 | """ |
1592 | 754 | def generate(*args, **kwargs): | 754 | def generate(*args, **kwargs): |
1595 | 755 | for value in sequence: | 755 | yield from sequence |
1594 | 756 | yield value | ||
1596 | 757 | self.call(generate) | 756 | self.call(generate) |
1597 | 758 | 757 | ||
1598 | 759 | def throw(self, exception): | 758 | def throw(self, exception): |
1599 | @@ -980,7 +979,7 @@ | |||
1600 | 980 | return self._events[0] | 979 | return self._events[0] |
1601 | 981 | 980 | ||
1602 | 982 | 981 | ||
1604 | 983 | class OrderedContext(object): | 982 | class OrderedContext: |
1605 | 984 | 983 | ||
1606 | 985 | def __init__(self, mocker): | 984 | def __init__(self, mocker): |
1607 | 986 | self._mocker = mocker | 985 | self._mocker = mocker |
1608 | @@ -1002,7 +1001,7 @@ | |||
1609 | 1002 | # -------------------------------------------------------------------- | 1001 | # -------------------------------------------------------------------- |
1610 | 1003 | # Mock object. | 1002 | # Mock object. |
1611 | 1004 | 1003 | ||
1613 | 1005 | class Mock(object): | 1004 | class Mock: |
1614 | 1006 | 1005 | ||
1615 | 1007 | def __init__(self, mocker, path=None, name=None, spec=None, type=None, | 1006 | def __init__(self, mocker, path=None, name=None, spec=None, type=None, |
1616 | 1008 | object=None, passthrough=False, patcher=None, count=True): | 1007 | object=None, passthrough=False, patcher=None, count=True): |
1617 | @@ -1044,7 +1043,7 @@ | |||
1618 | 1044 | 1043 | ||
1619 | 1045 | def __getattribute__(self, name): | 1044 | def __getattribute__(self, name): |
1620 | 1046 | if name.startswith("__mocker_"): | 1045 | if name.startswith("__mocker_"): |
1622 | 1047 | return super(Mock, self).__getattribute__(name) | 1046 | return super().__getattribute__(name) |
1623 | 1048 | if name == "__class__": | 1047 | if name == "__class__": |
1624 | 1049 | if self.__mocker__.is_recording() or self.__mocker_type__ is None: | 1048 | if self.__mocker__.is_recording() or self.__mocker_type__ is None: |
1625 | 1050 | return type(self) | 1049 | return type(self) |
1626 | @@ -1053,7 +1052,7 @@ | |||
1627 | 1053 | 1052 | ||
1628 | 1054 | def __setattr__(self, name, value): | 1053 | def __setattr__(self, name, value): |
1629 | 1055 | if name.startswith("__mocker_"): | 1054 | if name.startswith("__mocker_"): |
1631 | 1056 | return super(Mock, self).__setattr__(name, value) | 1055 | return super().__setattr__(name, value) |
1632 | 1057 | return self.__mocker_act__("setattr", (name, value)) | 1056 | return self.__mocker_act__("setattr", (name, value)) |
1633 | 1058 | 1057 | ||
1634 | 1059 | def __delattr__(self, name): | 1058 | def __delattr__(self, name): |
1635 | @@ -1131,7 +1130,7 @@ | |||
1636 | 1131 | # -------------------------------------------------------------------- | 1130 | # -------------------------------------------------------------------- |
1637 | 1132 | # Action and path. | 1131 | # Action and path. |
1638 | 1133 | 1132 | ||
1640 | 1134 | class Action(object): | 1133 | class Action: |
1641 | 1135 | 1134 | ||
1642 | 1136 | def __init__(self, kind, args, kwargs, path=None): | 1135 | def __init__(self, kind, args, kwargs, path=None): |
1643 | 1137 | self.kind = kind | 1136 | self.kind = kind |
1644 | @@ -1200,7 +1199,7 @@ | |||
1645 | 1200 | return result | 1199 | return result |
1646 | 1201 | 1200 | ||
1647 | 1202 | 1201 | ||
1649 | 1203 | class Path(object): | 1202 | class Path: |
1650 | 1204 | 1203 | ||
1651 | 1205 | def __init__(self, root_mock, root_object=None, actions=()): | 1204 | def __init__(self, root_mock, root_object=None, actions=()): |
1652 | 1206 | self.root_mock = root_mock | 1205 | self.root_mock = root_mock |
1653 | @@ -1293,7 +1292,7 @@ | |||
1654 | 1293 | return result | 1292 | return result |
1655 | 1294 | 1293 | ||
1656 | 1295 | 1294 | ||
1658 | 1296 | class SpecialArgument(object): | 1295 | class SpecialArgument: |
1659 | 1297 | """Base for special arguments for matching parameters.""" | 1296 | """Base for special arguments for matching parameters.""" |
1660 | 1298 | 1297 | ||
1661 | 1299 | def __init__(self, object=None): | 1298 | def __init__(self, object=None): |
1662 | @@ -1450,7 +1449,7 @@ | |||
1663 | 1450 | # -------------------------------------------------------------------- | 1449 | # -------------------------------------------------------------------- |
1664 | 1451 | # Event and task base. | 1450 | # Event and task base. |
1665 | 1452 | 1451 | ||
1667 | 1453 | class Event(object): | 1452 | class Event: |
1668 | 1454 | """Aggregation of tasks that keep track of a recorded action. | 1453 | """Aggregation of tasks that keep track of a recorded action. |
1669 | 1455 | 1454 | ||
1670 | 1456 | An event represents something that may or may not happen while the | 1455 | An event represents something that may or may not happen while the |
1671 | @@ -1591,7 +1590,7 @@ | |||
1672 | 1591 | return False | 1590 | return False |
1673 | 1592 | 1591 | ||
1674 | 1593 | 1592 | ||
1676 | 1594 | class Task(object): | 1593 | class Task: |
1677 | 1595 | """Element used to track one specific aspect on an event. | 1594 | """Element used to track one specific aspect on an event. |
1678 | 1596 | 1595 | ||
1679 | 1597 | A task is responsible for adding any kind of logic to an event. | 1596 | A task is responsible for adding any kind of logic to an event. |
1680 | @@ -1918,7 +1917,7 @@ | |||
1681 | 1918 | referrer[key] = install | 1917 | referrer[key] = install |
1682 | 1919 | 1918 | ||
1683 | 1920 | 1919 | ||
1685 | 1921 | class Undefined(object): | 1920 | class Undefined: |
1686 | 1922 | 1921 | ||
1687 | 1923 | def __repr__(self): | 1922 | def __repr__(self): |
1688 | 1924 | return "Undefined" | 1923 | return "Undefined" |
1689 | @@ -1929,7 +1928,7 @@ | |||
1690 | 1929 | class Patcher(Task): | 1928 | class Patcher(Task): |
1691 | 1930 | 1929 | ||
1692 | 1931 | def __init__(self): | 1930 | def __init__(self): |
1694 | 1932 | super(Patcher, self).__init__() | 1931 | super().__init__() |
1695 | 1933 | self._monitored = {} # {kind: {id(object): object}} | 1932 | self._monitored = {} # {kind: {id(object): object}} |
1696 | 1934 | self._patched = {} | 1933 | self._patched = {} |
1697 | 1935 | 1934 | ||
1698 | @@ -1941,7 +1940,7 @@ | |||
1699 | 1941 | cls = type(obj) | 1940 | cls = type(obj) |
1700 | 1942 | if issubclass(cls, type): | 1941 | if issubclass(cls, type): |
1701 | 1943 | cls = obj | 1942 | cls = obj |
1703 | 1944 | bases = set([id(base) for base in cls.__mro__]) | 1943 | bases = {id(base) for base in cls.__mro__} |
1704 | 1945 | bases.intersection_update(monitored) | 1944 | bases.intersection_update(monitored) |
1705 | 1946 | return bool(bases) | 1945 | return bool(bases) |
1706 | 1947 | return False | 1946 | return False |
1707 | @@ -2026,7 +2025,7 @@ | |||
1708 | 2026 | raise | 2025 | raise |
1709 | 2027 | 2026 | ||
1710 | 2028 | 2027 | ||
1712 | 2029 | class PatchedMethod(object): | 2028 | class PatchedMethod: |
1713 | 2030 | 2029 | ||
1714 | 2031 | def __init__(self, kind, unpatched, is_monitoring): | 2030 | def __init__(self, kind, unpatched, is_monitoring): |
1715 | 2032 | self._kind = kind | 2031 | self._kind = kind |
1716 | 2033 | 2032 | ||
1717 | === modified file 'storm/tests/properties.py' | |||
1718 | --- storm/tests/properties.py 2024-03-04 10:59:55 +0000 | |||
1719 | +++ storm/tests/properties.py 2024-03-13 16:26:38 +0000 | |||
1720 | @@ -45,7 +45,7 @@ | |||
1721 | 45 | 45 | ||
1722 | 46 | def setUp(self): | 46 | def setUp(self): |
1723 | 47 | TestHelper.setUp(self) | 47 | TestHelper.setUp(self) |
1725 | 48 | class Class(object): | 48 | class Class: |
1726 | 49 | __storm_table__ = "mytable" | 49 | __storm_table__ = "mytable" |
1727 | 50 | prop1 = Custom("column1", primary=True) | 50 | prop1 = Custom("column1", primary=True) |
1728 | 51 | prop2 = Custom() | 51 | prop2 = Custom() |
1729 | @@ -108,10 +108,10 @@ | |||
1730 | 108 | def test_variable_factory_validator_attribute(self): | 108 | def test_variable_factory_validator_attribute(self): |
1731 | 109 | # Should work even if we make things harder by reusing properties. | 109 | # Should work even if we make things harder by reusing properties. |
1732 | 110 | prop = Custom() | 110 | prop = Custom() |
1734 | 111 | class Class1(object): | 111 | class Class1: |
1735 | 112 | __storm_table__ = "table1" | 112 | __storm_table__ = "table1" |
1736 | 113 | prop1 = prop | 113 | prop1 = prop |
1738 | 114 | class Class2(object): | 114 | class Class2: |
1739 | 115 | __storm_table__ = "table2" | 115 | __storm_table__ = "table2" |
1740 | 116 | prop2 = prop | 116 | prop2 = prop |
1741 | 117 | args = [] | 117 | args = [] |
1742 | @@ -152,7 +152,7 @@ | |||
1743 | 152 | args[:] = obj, attr, value | 152 | args[:] = obj, attr, value |
1744 | 153 | return 42 | 153 | return 42 |
1745 | 154 | 154 | ||
1747 | 155 | class Class(object): | 155 | class Class: |
1748 | 156 | __storm_table__ = "mytable" | 156 | __storm_table__ = "mytable" |
1749 | 157 | prop = Custom("column", primary=True, validator=validator) | 157 | prop = Custom("column", primary=True, validator=validator) |
1750 | 158 | 158 | ||
1751 | @@ -299,10 +299,10 @@ | |||
1752 | 299 | right now it works, and we should try not to break it. | 299 | right now it works, and we should try not to break it. |
1753 | 300 | """ | 300 | """ |
1754 | 301 | prop = Custom() | 301 | prop = Custom() |
1756 | 302 | class Class1(object): | 302 | class Class1: |
1757 | 303 | __storm_table__ = "table1" | 303 | __storm_table__ = "table1" |
1758 | 304 | prop1 = prop | 304 | prop1 = prop |
1760 | 305 | class Class2(object): | 305 | class Class2: |
1761 | 306 | __storm_table__ = "table2" | 306 | __storm_table__ = "table2" |
1762 | 307 | prop2 = prop | 307 | prop2 = prop |
1763 | 308 | self.assertEqual(Class1.prop1.name, "prop1") | 308 | self.assertEqual(Class1.prop1.name, "prop1") |
1764 | @@ -316,7 +316,7 @@ | |||
1765 | 316 | def setup(self, property, *args, **kwargs): | 316 | def setup(self, property, *args, **kwargs): |
1766 | 317 | prop2_kwargs = kwargs.pop("prop2_kwargs", {}) | 317 | prop2_kwargs = kwargs.pop("prop2_kwargs", {}) |
1767 | 318 | kwargs["primary"] = True | 318 | kwargs["primary"] = True |
1769 | 319 | class Class(object): | 319 | class Class: |
1770 | 320 | __storm_table__ = "mytable" | 320 | __storm_table__ = "mytable" |
1771 | 321 | prop1 = property("column1", *args, **kwargs) | 321 | prop1 = property("column1", *args, **kwargs) |
1772 | 322 | prop2 = property(**prop2_kwargs) | 322 | prop2 = property(**prop2_kwargs) |
1773 | @@ -432,10 +432,10 @@ | |||
1774 | 432 | self.obj.prop2 = None | 432 | self.obj.prop2 = None |
1775 | 433 | self.assertEqual(self.obj.prop2, None) | 433 | self.assertEqual(self.obj.prop2, None) |
1776 | 434 | 434 | ||
1778 | 435 | self.assertRaises(TypeError, setattr, self.obj, "prop1", u"unicode") | 435 | self.assertRaises(TypeError, setattr, self.obj, "prop1", "unicode") |
1779 | 436 | 436 | ||
1780 | 437 | def test_unicode(self): | 437 | def test_unicode(self): |
1782 | 438 | self.setup(Unicode, default=u"def", allow_none=False) | 438 | self.setup(Unicode, default="def", allow_none=False) |
1783 | 439 | 439 | ||
1784 | 440 | self.assertTrue(isinstance(self.column1, Column)) | 440 | self.assertTrue(isinstance(self.column1, Column)) |
1785 | 441 | self.assertTrue(isinstance(self.column2, Column)) | 441 | self.assertTrue(isinstance(self.column2, Column)) |
1786 | @@ -446,7 +446,7 @@ | |||
1787 | 446 | self.assertTrue(isinstance(self.variable1, UnicodeVariable)) | 446 | self.assertTrue(isinstance(self.variable1, UnicodeVariable)) |
1788 | 447 | self.assertTrue(isinstance(self.variable2, UnicodeVariable)) | 447 | self.assertTrue(isinstance(self.variable2, UnicodeVariable)) |
1789 | 448 | 448 | ||
1791 | 449 | self.assertEqual(self.obj.prop1, u"def") | 449 | self.assertEqual(self.obj.prop1, "def") |
1792 | 450 | self.assertRaises(NoneError, setattr, self.obj, "prop1", None) | 450 | self.assertRaises(NoneError, setattr, self.obj, "prop1", None) |
1793 | 451 | self.obj.prop2 = None | 451 | self.obj.prop2 = None |
1794 | 452 | self.assertEqual(self.obj.prop2, None) | 452 | self.assertEqual(self.obj.prop2, None) |
1795 | @@ -798,7 +798,7 @@ | |||
1796 | 798 | self.assertEqual(changes, [(self.variable1, None, ["a"], False)]) | 798 | self.assertEqual(changes, [(self.variable1, None, ["a"], False)]) |
1797 | 799 | 799 | ||
1798 | 800 | def test_variable_factory_arguments(self): | 800 | def test_variable_factory_arguments(self): |
1800 | 801 | class Class(object): | 801 | class Class: |
1801 | 802 | __storm_table__ = "test" | 802 | __storm_table__ = "test" |
1802 | 803 | id = Int(primary=True) | 803 | id = Int(primary=True) |
1803 | 804 | 804 | ||
1804 | @@ -812,7 +812,7 @@ | |||
1805 | 812 | (Int, IntVariable, 1), | 812 | (Int, IntVariable, 1), |
1806 | 813 | (Float, FloatVariable, 1.1), | 813 | (Float, FloatVariable, 1.1), |
1807 | 814 | (Bytes, BytesVariable, b"str"), | 814 | (Bytes, BytesVariable, b"str"), |
1809 | 815 | (Unicode, UnicodeVariable, u"unicode"), | 815 | (Unicode, UnicodeVariable, "unicode"), |
1810 | 816 | (DateTime, DateTimeVariable, datetime.now()), | 816 | (DateTime, DateTimeVariable, datetime.now()), |
1811 | 817 | (Date, DateVariable, date.today()), | 817 | (Date, DateVariable, date.today()), |
1812 | 818 | (Time, TimeVariable, datetime.now().time()), | 818 | (Time, TimeVariable, datetime.now().time()), |
1813 | @@ -881,7 +881,7 @@ | |||
1814 | 881 | def setUp(self): | 881 | def setUp(self): |
1815 | 882 | TestHelper.setUp(self) | 882 | TestHelper.setUp(self) |
1816 | 883 | 883 | ||
1818 | 884 | class Class(object): | 884 | class Class: |
1819 | 885 | __storm_table__ = "mytable" | 885 | __storm_table__ = "mytable" |
1820 | 886 | prop1 = Property("column1", primary=True) | 886 | prop1 = Property("column1", primary=True) |
1821 | 887 | prop2 = Property() | 887 | prop2 = Property() |
1822 | 888 | 888 | ||
1823 | === modified file 'storm/tests/schema/patch.py' | |||
1824 | --- storm/tests/schema/patch.py 2024-03-04 10:59:55 +0000 | |||
1825 | +++ storm/tests/schema/patch.py 2024-03-13 16:26:38 +0000 | |||
1826 | @@ -75,7 +75,7 @@ | |||
1827 | 75 | """ | 75 | """ |
1828 | 76 | 76 | ||
1829 | 77 | 77 | ||
1831 | 78 | class MockPatchStore(object): | 78 | class MockPatchStore: |
1832 | 79 | 79 | ||
1833 | 80 | def __init__(self, database, patches=[]): | 80 | def __init__(self, database, patches=[]): |
1834 | 81 | self.database = database | 81 | self.database = database |
1835 | @@ -103,7 +103,7 @@ | |||
1836 | 103 | class PatchApplierTest(MockerTestCase): | 103 | class PatchApplierTest(MockerTestCase): |
1837 | 104 | 104 | ||
1838 | 105 | def setUp(self): | 105 | def setUp(self): |
1840 | 106 | super(PatchApplierTest, self).setUp() | 106 | super().setUp() |
1841 | 107 | 107 | ||
1842 | 108 | self.patchdir = self.makeDir() | 108 | self.patchdir = self.makeDir() |
1843 | 109 | self.pkgdir = os.path.join(self.patchdir, "mypackage") | 109 | self.pkgdir = os.path.join(self.patchdir, "mypackage") |
1844 | @@ -143,7 +143,7 @@ | |||
1845 | 143 | self.another_store.commit() | 143 | self.another_store.commit() |
1846 | 144 | self.prepare_for_transaction_check() | 144 | self.prepare_for_transaction_check() |
1847 | 145 | 145 | ||
1849 | 146 | class Committer(object): | 146 | class Committer: |
1850 | 147 | 147 | ||
1851 | 148 | def commit(committer): | 148 | def commit(committer): |
1852 | 149 | self.store.commit() | 149 | self.store.commit() |
1853 | @@ -158,7 +158,7 @@ | |||
1854 | 158 | self.committer) | 158 | self.committer) |
1855 | 159 | 159 | ||
1856 | 160 | def tearDown(self): | 160 | def tearDown(self): |
1858 | 161 | super(PatchApplierTest, self).tearDown() | 161 | super().tearDown() |
1859 | 162 | self.committer.rollback() | 162 | self.committer.rollback() |
1860 | 163 | sys.path.remove(self.patchdir) | 163 | sys.path.remove(self.patchdir) |
1861 | 164 | for name in list(sys.modules): | 164 | for name in list(sys.modules): |
1862 | @@ -329,7 +329,7 @@ | |||
1863 | 329 | patches = [Patch(42), Patch(380), Patch(381)] | 329 | patches = [Patch(42), Patch(380), Patch(381)] |
1864 | 330 | my_store = MockPatchStore("database", patches=patches) | 330 | my_store = MockPatchStore("database", patches=patches) |
1865 | 331 | patch_applier = PatchApplier(my_store, self.mypackage) | 331 | patch_applier = PatchApplier(my_store, self.mypackage) |
1867 | 332 | self.assertEqual(set([381]), | 332 | self.assertEqual({381}, |
1868 | 333 | patch_applier.get_unknown_patch_versions()) | 333 | patch_applier.get_unknown_patch_versions()) |
1869 | 334 | 334 | ||
1870 | 335 | def test_no_unknown_patch_versions(self): | 335 | def test_no_unknown_patch_versions(self): |
1871 | @@ -410,7 +410,7 @@ | |||
1872 | 410 | class PatchSetTest(MockerTestCase): | 410 | class PatchSetTest(MockerTestCase): |
1873 | 411 | 411 | ||
1874 | 412 | def setUp(self): | 412 | def setUp(self): |
1876 | 413 | super(PatchSetTest, self).setUp() | 413 | super().setUp() |
1877 | 414 | self.sys_dir = self.makeDir() | 414 | self.sys_dir = self.makeDir() |
1878 | 415 | self.package_dir = os.path.join(self.sys_dir, "mypackage") | 415 | self.package_dir = os.path.join(self.sys_dir, "mypackage") |
1879 | 416 | os.makedirs(self.package_dir) | 416 | os.makedirs(self.package_dir) |
1880 | @@ -423,7 +423,7 @@ | |||
1881 | 423 | self.patch_package = PatchSet(mypackage, sub_level="foo") | 423 | self.patch_package = PatchSet(mypackage, sub_level="foo") |
1882 | 424 | 424 | ||
1883 | 425 | def tearDown(self): | 425 | def tearDown(self): |
1885 | 426 | super(PatchSetTest, self).tearDown() | 426 | super().tearDown() |
1886 | 427 | for name in list(sys.modules): | 427 | for name in list(sys.modules): |
1887 | 428 | if name == "mypackage" or name.startswith("mypackage."): | 428 | if name == "mypackage" or name.startswith("mypackage."): |
1888 | 429 | del sys.modules[name] | 429 | del sys.modules[name] |
1889 | 430 | 430 | ||
1890 | === modified file 'storm/tests/schema/schema.py' | |||
1891 | --- storm/tests/schema/schema.py 2024-03-04 10:59:55 +0000 | |||
1892 | +++ storm/tests/schema/schema.py 2024-03-13 16:26:38 +0000 | |||
1893 | @@ -27,7 +27,7 @@ | |||
1894 | 27 | from storm.tests.mocker import MockerTestCase | 27 | from storm.tests.mocker import MockerTestCase |
1895 | 28 | 28 | ||
1896 | 29 | 29 | ||
1898 | 30 | class Package(object): | 30 | class Package: |
1899 | 31 | 31 | ||
1900 | 32 | def __init__(self, package_dir, name): | 32 | def __init__(self, package_dir, name): |
1901 | 33 | self.name = name | 33 | self.name = name |
1902 | @@ -43,7 +43,7 @@ | |||
1903 | 43 | class SchemaTest(MockerTestCase): | 43 | class SchemaTest(MockerTestCase): |
1904 | 44 | 44 | ||
1905 | 45 | def setUp(self): | 45 | def setUp(self): |
1907 | 46 | super(SchemaTest, self).setUp() | 46 | super().setUp() |
1908 | 47 | self.database = create_database("sqlite:///%s" % self.makeFile()) | 47 | self.database = create_database("sqlite:///%s" % self.makeFile()) |
1909 | 48 | self.store = Store(self.database) | 48 | self.store = Store(self.database) |
1910 | 49 | 49 | ||
1911 | @@ -68,7 +68,7 @@ | |||
1912 | 68 | elif any(name.startswith("%s." % x) for x in self._package_names): | 68 | elif any(name.startswith("%s." % x) for x in self._package_names): |
1913 | 69 | del sys.modules[name] | 69 | del sys.modules[name] |
1914 | 70 | 70 | ||
1916 | 71 | super(SchemaTest, self).tearDown() | 71 | super().tearDown() |
1917 | 72 | 72 | ||
1918 | 73 | def create_package(self, base_dir, name, init_module=None): | 73 | def create_package(self, base_dir, name, init_module=None): |
1919 | 74 | """Create a Python package. | 74 | """Create a Python package. |
1920 | @@ -169,7 +169,7 @@ | |||
1921 | 169 | self.schema.create(self.store) | 169 | self.schema.create(self.store) |
1922 | 170 | self.store.execute("INSERT INTO person (id, name) VALUES (1, 'Jane')") | 170 | self.store.execute("INSERT INTO person (id, name) VALUES (1, 'Jane')") |
1923 | 171 | self.assertEqual(list(self.store.execute("SELECT * FROM person")), | 171 | self.assertEqual(list(self.store.execute("SELECT * FROM person")), |
1925 | 172 | [(1, u"Jane")]) | 172 | [(1, "Jane")]) |
1926 | 173 | self.schema.delete(self.store) | 173 | self.schema.delete(self.store) |
1927 | 174 | self.assertEqual(list(self.store.execute("SELECT * FROM person")), []) | 174 | self.assertEqual(list(self.store.execute("SELECT * FROM person")), []) |
1928 | 175 | 175 | ||
1929 | @@ -214,7 +214,7 @@ | |||
1930 | 214 | self.store.execute( | 214 | self.store.execute( |
1931 | 215 | "INSERT INTO person (id, name, phone) VALUES (1, 'Jane', '123')") | 215 | "INSERT INTO person (id, name, phone) VALUES (1, 'Jane', '123')") |
1932 | 216 | self.assertEqual(list(self.store.execute("SELECT * FROM person")), | 216 | self.assertEqual(list(self.store.execute("SELECT * FROM person")), |
1934 | 217 | [(1, u"Jane", u"123")]) | 217 | [(1, "Jane", "123")]) |
1935 | 218 | 218 | ||
1936 | 219 | def test_advance(self): | 219 | def test_advance(self): |
1937 | 220 | """ | 220 | """ |
1938 | @@ -235,4 +235,4 @@ | |||
1939 | 235 | self.store.execute( | 235 | self.store.execute( |
1940 | 236 | "INSERT INTO person (id, name, phone) VALUES (1, 'Jane', '123')") | 236 | "INSERT INTO person (id, name, phone) VALUES (1, 'Jane', '123')") |
1941 | 237 | self.assertEqual(list(self.store.execute("SELECT * FROM person")), | 237 | self.assertEqual(list(self.store.execute("SELECT * FROM person")), |
1943 | 238 | [(1, u"Jane", u"123")]) | 238 | [(1, "Jane", "123")]) |
1944 | 239 | 239 | ||
1945 | === modified file 'storm/tests/schema/sharding.py' | |||
1946 | --- storm/tests/schema/sharding.py 2024-03-04 10:59:55 +0000 | |||
1947 | +++ storm/tests/schema/sharding.py 2024-03-13 16:26:38 +0000 | |||
1948 | @@ -23,7 +23,7 @@ | |||
1949 | 23 | from storm.tests.mocker import MockerTestCase | 23 | from storm.tests.mocker import MockerTestCase |
1950 | 24 | 24 | ||
1951 | 25 | 25 | ||
1953 | 26 | class FakeSchema(object): | 26 | class FakeSchema: |
1954 | 27 | 27 | ||
1955 | 28 | patches = 2 | 28 | patches = 2 |
1956 | 29 | 29 | ||
1957 | @@ -50,7 +50,7 @@ | |||
1958 | 50 | self.applied.append((store, store.patch)) | 50 | self.applied.append((store, store.patch)) |
1959 | 51 | 51 | ||
1960 | 52 | 52 | ||
1962 | 53 | class FakeStore(object): | 53 | class FakeStore: |
1963 | 54 | 54 | ||
1964 | 55 | pristine = True # If no schema was ever applied | 55 | pristine = True # If no schema was ever applied |
1965 | 56 | patch = 0 # Current patch level of the store | 56 | patch = 0 # Current patch level of the store |
1966 | @@ -59,7 +59,7 @@ | |||
1967 | 59 | class ShardingTest(MockerTestCase): | 59 | class ShardingTest(MockerTestCase): |
1968 | 60 | 60 | ||
1969 | 61 | def setUp(self): | 61 | def setUp(self): |
1971 | 62 | super(ShardingTest, self).setUp() | 62 | super().setUp() |
1972 | 63 | self.store = FakeStore() | 63 | self.store = FakeStore() |
1973 | 64 | self.schema = FakeSchema() | 64 | self.schema = FakeSchema() |
1974 | 65 | self.sharding = Sharding() | 65 | self.sharding = Sharding() |
1975 | 66 | 66 | ||
1976 | === modified file 'storm/tests/sqlobject.py' | |||
1977 | --- storm/tests/sqlobject.py 2024-03-04 10:59:55 +0000 | |||
1978 | +++ storm/tests/sqlobject.py 2024-03-13 16:26:38 +0000 | |||
1979 | @@ -343,7 +343,7 @@ | |||
1980 | 343 | self.assertEqual(nobody, None) | 343 | self.assertEqual(nobody, None) |
1981 | 344 | 344 | ||
1982 | 345 | # SQLBuilder style expression: | 345 | # SQLBuilder style expression: |
1984 | 346 | person = self.Person.selectFirst(LIKE(self.Person.q.name, u"John%"), | 346 | person = self.Person.selectFirst(LIKE(self.Person.q.name, "John%"), |
1985 | 347 | orderBy="name") | 347 | orderBy="name") |
1986 | 348 | self.assertNotEqual(person, None) | 348 | self.assertNotEqual(person, None) |
1987 | 349 | self.assertEqual(person.name, "John Doe") | 349 | self.assertEqual(person.name, "John Doe") |
1988 | @@ -463,8 +463,8 @@ | |||
1989 | 463 | class Person(self.SQLObject): | 463 | class Person(self.SQLObject): |
1990 | 464 | name = StringCol(storm_validator=validator) | 464 | name = StringCol(storm_validator=validator) |
1991 | 465 | person = Person.get(2) | 465 | person = Person.get(2) |
1994 | 466 | person.name = u'foo' | 466 | person.name = 'foo' |
1995 | 467 | self.assertEqual(calls, [(person, 'name', u'foo')]) | 467 | self.assertEqual(calls, [(person, 'name', 'foo')]) |
1996 | 468 | 468 | ||
1997 | 469 | def test_string_col(self): | 469 | def test_string_col(self): |
1998 | 470 | class Person(self.SQLObject): | 470 | class Person(self.SQLObject): |
1999 | @@ -1200,21 +1200,21 @@ | |||
2000 | 1200 | class Person(self.Person): | 1200 | class Person(self.Person): |
2001 | 1201 | def set(self, **kw): | 1201 | def set(self, **kw): |
2002 | 1202 | kw["id"] += 1 | 1202 | kw["id"] += 1 |
2004 | 1203 | super(Person, self).set(**kw) | 1203 | super().set(**kw) |
2005 | 1204 | person = Person(id=3, name="John Moe") | 1204 | person = Person(id=3, name="John Moe") |
2006 | 1205 | self.assertEqual(person.id, 4) | 1205 | self.assertEqual(person.id, 4) |
2007 | 1206 | self.assertEqual(person.name, "John Moe") | 1206 | self.assertEqual(person.name, "John Moe") |
2008 | 1207 | 1207 | ||
2009 | 1208 | def test_CONTAINSSTRING(self): | 1208 | def test_CONTAINSSTRING(self): |
2021 | 1209 | expr = CONTAINSSTRING(self.Person.q.name, u"Do") | 1209 | expr = CONTAINSSTRING(self.Person.q.name, "Do") |
2022 | 1210 | result = self.Person.select(expr) | 1210 | result = self.Person.select(expr) |
2023 | 1211 | self.assertEqual([person.name for person in result], | 1211 | self.assertEqual([person.name for person in result], |
2024 | 1212 | [u"John Doe"]) | 1212 | ["John Doe"]) |
2025 | 1213 | 1213 | ||
2026 | 1214 | result[0].name = u"Funny !%_ Name" | 1214 | result[0].name = "Funny !%_ Name" |
2027 | 1215 | 1215 | ||
2028 | 1216 | expr = NOT(CONTAINSSTRING(self.Person.q.name, u"!%_")) | 1216 | expr = NOT(CONTAINSSTRING(self.Person.q.name, "!%_")) |
2029 | 1217 | result = self.Person.select(expr) | 1217 | result = self.Person.select(expr) |
2030 | 1218 | self.assertEqual([person.name for person in result], | 1218 | self.assertEqual([person.name for person in result], |
2031 | 1219 | [u"John Joe"]) | 1219 | ["John Joe"]) |
2032 | 1220 | 1220 | ||
2033 | 1221 | 1221 | ||
2034 | === modified file 'storm/tests/store/base.py' | |||
2035 | --- storm/tests/store/base.py 2024-03-04 10:59:55 +0000 | |||
2036 | +++ storm/tests/store/base.py 2024-03-13 16:26:38 +0000 | |||
2037 | @@ -1,4 +1,3 @@ | |||
2038 | 1 | # -*- coding: utf-8 -*- | ||
2039 | 2 | # | 1 | # |
2040 | 3 | # Copyright (c) 2006, 2007 Canonical | 2 | # Copyright (c) 2006, 2007 Canonical |
2041 | 4 | # | 3 | # |
2042 | @@ -49,36 +48,36 @@ | |||
2043 | 49 | from storm.tests.helper import TestHelper | 48 | from storm.tests.helper import TestHelper |
2044 | 50 | 49 | ||
2045 | 51 | 50 | ||
2047 | 52 | class Foo(object): | 51 | class Foo: |
2048 | 53 | __storm_table__ = "foo" | 52 | __storm_table__ = "foo" |
2049 | 54 | id = Int(primary=True) | 53 | id = Int(primary=True) |
2050 | 55 | title = Unicode() | 54 | title = Unicode() |
2051 | 56 | 55 | ||
2053 | 57 | class Bar(object): | 56 | class Bar: |
2054 | 58 | __storm_table__ = "bar" | 57 | __storm_table__ = "bar" |
2055 | 59 | id = Int(primary=True) | 58 | id = Int(primary=True) |
2056 | 60 | title = Unicode() | 59 | title = Unicode() |
2057 | 61 | foo_id = Int() | 60 | foo_id = Int() |
2058 | 62 | foo = Reference(foo_id, Foo.id) | 61 | foo = Reference(foo_id, Foo.id) |
2059 | 63 | 62 | ||
2061 | 64 | class UniqueID(object): | 63 | class UniqueID: |
2062 | 65 | __storm_table__ = "unique_id" | 64 | __storm_table__ = "unique_id" |
2063 | 66 | id = UUID(primary=True) | 65 | id = UUID(primary=True) |
2064 | 67 | def __init__(self, id): | 66 | def __init__(self, id): |
2065 | 68 | self.id = id | 67 | self.id = id |
2066 | 69 | 68 | ||
2068 | 70 | class Blob(object): | 69 | class Blob: |
2069 | 71 | __storm_table__ = "bin" | 70 | __storm_table__ = "bin" |
2070 | 72 | id = Int(primary=True) | 71 | id = Int(primary=True) |
2071 | 73 | bin = Bytes() | 72 | bin = Bytes() |
2072 | 74 | 73 | ||
2074 | 75 | class Link(object): | 74 | class Link: |
2075 | 76 | __storm_table__ = "link" | 75 | __storm_table__ = "link" |
2076 | 77 | __storm_primary__ = "foo_id", "bar_id" | 76 | __storm_primary__ = "foo_id", "bar_id" |
2077 | 78 | foo_id = Int() | 77 | foo_id = Int() |
2078 | 79 | bar_id = Int() | 78 | bar_id = Int() |
2079 | 80 | 79 | ||
2081 | 81 | class SelfRef(object): | 80 | class SelfRef: |
2082 | 82 | __storm_table__ = "selfref" | 81 | __storm_table__ = "selfref" |
2083 | 83 | id = Int(primary=True) | 82 | id = Int(primary=True) |
2084 | 84 | title = Unicode() | 83 | title = Unicode() |
2085 | @@ -110,14 +109,14 @@ | |||
2086 | 110 | order_by=Bar.title) | 109 | order_by=Bar.title) |
2087 | 111 | 110 | ||
2088 | 112 | 111 | ||
2090 | 113 | class FooValue(object): | 112 | class FooValue: |
2091 | 114 | __storm_table__ = "foovalue" | 113 | __storm_table__ = "foovalue" |
2092 | 115 | id = Int(primary=True) | 114 | id = Int(primary=True) |
2093 | 116 | foo_id = Int() | 115 | foo_id = Int() |
2094 | 117 | value1 = Int() | 116 | value1 = Int() |
2095 | 118 | value2 = Int() | 117 | value2 = Int() |
2096 | 119 | 118 | ||
2098 | 120 | class BarProxy(object): | 119 | class BarProxy: |
2099 | 121 | __storm_table__ = "bar" | 120 | __storm_table__ = "bar" |
2100 | 122 | id = Int(primary=True) | 121 | id = Int(primary=True) |
2101 | 123 | title = Unicode() | 122 | title = Unicode() |
2102 | @@ -125,7 +124,7 @@ | |||
2103 | 125 | foo = Reference(foo_id, Foo.id) | 124 | foo = Reference(foo_id, Foo.id) |
2104 | 126 | foo_title = Proxy(foo, Foo.title) | 125 | foo_title = Proxy(foo, Foo.title) |
2105 | 127 | 126 | ||
2107 | 128 | class Money(object): | 127 | class Money: |
2108 | 129 | __storm_table__ = "money" | 128 | __storm_table__ = "money" |
2109 | 130 | id = Int(primary=True) | 129 | id = Int(primary=True) |
2110 | 131 | value = Decimal() | 130 | value = Decimal() |
2111 | @@ -134,17 +133,17 @@ | |||
2112 | 134 | class DecorateVariable(Variable): | 133 | class DecorateVariable(Variable): |
2113 | 135 | 134 | ||
2114 | 136 | def parse_get(self, value, to_db): | 135 | def parse_get(self, value, to_db): |
2116 | 137 | return u"to_%s(%s)" % (to_db and "db" or "py", value) | 136 | return "to_%s(%s)" % (to_db and "db" or "py", value) |
2117 | 138 | 137 | ||
2118 | 139 | def parse_set(self, value, from_db): | 138 | def parse_set(self, value, from_db): |
2120 | 140 | return u"from_%s(%s)" % (from_db and "db" or "py", value) | 139 | return "from_%s(%s)" % (from_db and "db" or "py", value) |
2121 | 141 | 140 | ||
2122 | 142 | 141 | ||
2123 | 143 | class FooVariable(Foo): | 142 | class FooVariable(Foo): |
2124 | 144 | title = Property(variable_class=DecorateVariable) | 143 | title = Property(variable_class=DecorateVariable) |
2125 | 145 | 144 | ||
2126 | 146 | 145 | ||
2128 | 147 | class DummyDatabase(object): | 146 | class DummyDatabase: |
2129 | 148 | 147 | ||
2130 | 149 | def connect(self, event=None): | 148 | def connect(self, event=None): |
2131 | 150 | return None | 149 | return None |
2132 | @@ -170,7 +169,7 @@ | |||
2133 | 170 | self.assertIdentical(store.get_database(), database) | 169 | self.assertIdentical(store.get_database(), database) |
2134 | 171 | 170 | ||
2135 | 172 | 171 | ||
2137 | 173 | class StoreTest(object): | 172 | class StoreTest: |
2138 | 174 | 173 | ||
2139 | 175 | def setUp(self): | 174 | def setUp(self): |
2140 | 176 | self.store = None | 175 | self.store = None |
2141 | @@ -307,7 +306,7 @@ | |||
2142 | 307 | 306 | ||
2143 | 308 | def test_execute_flushes(self): | 307 | def test_execute_flushes(self): |
2144 | 309 | foo = self.store.get(Foo, 10) | 308 | foo = self.store.get(Foo, 10) |
2146 | 310 | foo.title = u"New Title" | 309 | foo.title = "New Title" |
2147 | 311 | 310 | ||
2148 | 312 | result = self.store.execute("SELECT title FROM foo WHERE id=10") | 311 | result = self.store.execute("SELECT title FROM foo WHERE id=10") |
2149 | 313 | self.assertEqual(result.get_one(), ("New Title",)) | 312 | self.assertEqual(result.get_one(), ("New Title",)) |
2150 | @@ -373,13 +372,13 @@ | |||
2151 | 373 | # After adding an object, no references should be needed in | 372 | # After adding an object, no references should be needed in |
2152 | 374 | # python for it still to be added to the database. | 373 | # python for it still to be added to the database. |
2153 | 375 | foo = Foo() | 374 | foo = Foo() |
2155 | 376 | foo.title = u"live" | 375 | foo.title = "live" |
2156 | 377 | self.store.add(foo) | 376 | self.store.add(foo) |
2157 | 378 | 377 | ||
2158 | 379 | del foo | 378 | del foo |
2159 | 380 | gc.collect() | 379 | gc.collect() |
2160 | 381 | 380 | ||
2162 | 382 | self.assertTrue(self.store.find(Foo, title=u"live").one()) | 381 | self.assertTrue(self.store.find(Foo, title="live").one()) |
2163 | 383 | 382 | ||
2164 | 384 | def test_obj_info_with_deleted_object(self): | 383 | def test_obj_info_with_deleted_object(self): |
2165 | 385 | # Let's try to put Storm in trouble by killing the object | 384 | # Let's try to put Storm in trouble by killing the object |
2166 | @@ -524,14 +523,14 @@ | |||
2167 | 524 | store. | 523 | store. |
2168 | 525 | """ | 524 | """ |
2169 | 526 | foo = self.store.get(Foo, 20) | 525 | foo = self.store.get(Foo, 20) |
2171 | 527 | foo.title = u"changed" | 526 | foo.title = "changed" |
2172 | 528 | self.store.block_implicit_flushes() | 527 | self.store.block_implicit_flushes() |
2173 | 529 | foo2 = self.store.find(Foo, Foo.id == 20).one() | 528 | foo2 = self.store.find(Foo, Foo.id == 20).one() |
2174 | 530 | self.store.unblock_implicit_flushes() | 529 | self.store.unblock_implicit_flushes() |
2175 | 531 | self.store.commit() | 530 | self.store.commit() |
2176 | 532 | 531 | ||
2177 | 533 | foo3 = self.store.find(Foo, Foo.id == 20).one() | 532 | foo3 = self.store.find(Foo, Foo.id == 20).one() |
2179 | 534 | self.assertEqual(foo3.title, u"changed") | 533 | self.assertEqual(foo3.title, "changed") |
2180 | 535 | 534 | ||
2181 | 536 | def test_obj_info_with_deleted_object_with_get(self): | 535 | def test_obj_info_with_deleted_object_with_get(self): |
2182 | 537 | # Same thing, but using get rather than find. | 536 | # Same thing, but using get rather than find. |
2183 | @@ -559,7 +558,7 @@ | |||
2184 | 559 | self.get_cache(self.store).set_size(0) | 558 | self.get_cache(self.store).set_size(0) |
2185 | 560 | 559 | ||
2186 | 561 | foo = self.store.get(Foo, 20) | 560 | foo = self.store.get(Foo, 20) |
2188 | 562 | foo.title = u"Changed" | 561 | foo.title = "Changed" |
2189 | 563 | foo.tainted = True | 562 | foo.tainted = True |
2190 | 564 | obj_info = get_obj_info(foo) | 563 | obj_info = get_obj_info(foo) |
2191 | 565 | 564 | ||
2192 | @@ -571,11 +570,11 @@ | |||
2193 | 571 | def test_get_tuple(self): | 570 | def test_get_tuple(self): |
2194 | 572 | class MyFoo(Foo): | 571 | class MyFoo(Foo): |
2195 | 573 | __storm_primary__ = "title", "id" | 572 | __storm_primary__ = "title", "id" |
2197 | 574 | foo = self.store.get(MyFoo, (u"Title 30", 10)) | 573 | foo = self.store.get(MyFoo, ("Title 30", 10)) |
2198 | 575 | self.assertEqual(foo.id, 10) | 574 | self.assertEqual(foo.id, 10) |
2199 | 576 | self.assertEqual(foo.title, "Title 30") | 575 | self.assertEqual(foo.title, "Title 30") |
2200 | 577 | 576 | ||
2202 | 578 | foo = self.store.get(MyFoo, (u"Title 20", 10)) | 577 | foo = self.store.get(MyFoo, ("Title 20", 10)) |
2203 | 579 | self.assertEqual(foo, None) | 578 | self.assertEqual(foo, None) |
2204 | 580 | 579 | ||
2205 | 581 | def test_of(self): | 580 | def test_of(self): |
2206 | @@ -635,13 +634,13 @@ | |||
2207 | 635 | 634 | ||
2208 | 636 | def test_find_expr(self): | 635 | def test_find_expr(self): |
2209 | 637 | result = self.store.find(Foo, Foo.id == 20, | 636 | result = self.store.find(Foo, Foo.id == 20, |
2211 | 638 | Foo.title == u"Title 20") | 637 | Foo.title == "Title 20") |
2212 | 639 | self.assertEqual([(foo.id, foo.title) for foo in result], [ | 638 | self.assertEqual([(foo.id, foo.title) for foo in result], [ |
2213 | 640 | (20, "Title 20"), | 639 | (20, "Title 20"), |
2214 | 641 | ]) | 640 | ]) |
2215 | 642 | 641 | ||
2216 | 643 | result = self.store.find(Foo, Foo.id == 10, | 642 | result = self.store.find(Foo, Foo.id == 10, |
2218 | 644 | Foo.title == u"Title 20") | 643 | Foo.title == "Title 20") |
2219 | 645 | self.assertEqual([(foo.id, foo.title) for foo in result], [ | 644 | self.assertEqual([(foo.id, foo.title) for foo in result], [ |
2220 | 646 | ]) | 645 | ]) |
2221 | 647 | 646 | ||
2222 | @@ -654,12 +653,12 @@ | |||
2223 | 654 | self.assertEqual(foo.title, "Title 20") | 653 | self.assertEqual(foo.title, "Title 20") |
2224 | 655 | 654 | ||
2225 | 656 | def test_find_keywords(self): | 655 | def test_find_keywords(self): |
2227 | 657 | result = self.store.find(Foo, id=20, title=u"Title 20") | 656 | result = self.store.find(Foo, id=20, title="Title 20") |
2228 | 658 | self.assertEqual([(foo.id, foo.title) for foo in result], [ | 657 | self.assertEqual([(foo.id, foo.title) for foo in result], [ |
2230 | 659 | (20, u"Title 20") | 658 | (20, "Title 20") |
2231 | 660 | ]) | 659 | ]) |
2232 | 661 | 660 | ||
2234 | 662 | result = self.store.find(Foo, id=10, title=u"Title 20") | 661 | result = self.store.find(Foo, id=10, title="Title 20") |
2235 | 663 | self.assertEqual([(foo.id, foo.title) for foo in result], [ | 662 | self.assertEqual([(foo.id, foo.title) for foo in result], [ |
2236 | 664 | ]) | 663 | ]) |
2237 | 665 | 664 | ||
2238 | @@ -1053,7 +1052,7 @@ | |||
2239 | 1053 | self.assertTrue(isinstance(title, str)) | 1052 | self.assertTrue(isinstance(title, str)) |
2240 | 1054 | 1053 | ||
2241 | 1055 | def test_find_max_with_empty_result_and_disallow_none(self): | 1054 | def test_find_max_with_empty_result_and_disallow_none(self): |
2243 | 1056 | class Bar(object): | 1055 | class Bar: |
2244 | 1057 | __storm_table__ = "bar" | 1056 | __storm_table__ = "bar" |
2245 | 1058 | id = Int(primary=True) | 1057 | id = Int(primary=True) |
2246 | 1059 | foo_id = Int(allow_none=False) | 1058 | foo_id = Int(allow_none=False) |
2247 | @@ -1074,7 +1073,7 @@ | |||
2248 | 1074 | self.assertTrue(isinstance(title, str)) | 1073 | self.assertTrue(isinstance(title, str)) |
2249 | 1075 | 1074 | ||
2250 | 1076 | def test_find_min_with_empty_result_and_disallow_none(self): | 1075 | def test_find_min_with_empty_result_and_disallow_none(self): |
2252 | 1077 | class Bar(object): | 1076 | class Bar: |
2253 | 1078 | __storm_table__ = "bar" | 1077 | __storm_table__ = "bar" |
2254 | 1079 | id = Int(primary=True) | 1078 | id = Int(primary=True) |
2255 | 1080 | foo_id = Int(allow_none=False) | 1079 | foo_id = Int(allow_none=False) |
2256 | @@ -1092,7 +1091,7 @@ | |||
2257 | 1092 | def test_find_avg_float(self): | 1091 | def test_find_avg_float(self): |
2258 | 1093 | foo = Foo() | 1092 | foo = Foo() |
2259 | 1094 | foo.id = 15 | 1093 | foo.id = 15 |
2261 | 1095 | foo.title = u"Title 15" | 1094 | foo.title = "Title 15" |
2262 | 1096 | self.store.add(foo) | 1095 | self.store.add(foo) |
2263 | 1097 | self.assertEqual(self.store.find(Foo).avg(Foo.id), 18.75) | 1096 | self.assertEqual(self.store.find(Foo).avg(Foo.id), 18.75) |
2264 | 1098 | 1097 | ||
2265 | @@ -1103,7 +1102,7 @@ | |||
2266 | 1103 | self.assertEqual(self.store.find(Foo).sum(Foo.id * 2), 120) | 1102 | self.assertEqual(self.store.find(Foo).sum(Foo.id * 2), 120) |
2267 | 1104 | 1103 | ||
2268 | 1105 | def test_find_sum_with_empty_result_and_disallow_none(self): | 1104 | def test_find_sum_with_empty_result_and_disallow_none(self): |
2270 | 1106 | class Bar(object): | 1105 | class Bar: |
2271 | 1107 | __storm_table__ = "bar" | 1106 | __storm_table__ = "bar" |
2272 | 1108 | id = Int(primary=True) | 1107 | id = Int(primary=True) |
2273 | 1109 | foo_id = Int(allow_none=False) | 1108 | foo_id = Int(allow_none=False) |
2274 | @@ -1203,7 +1202,7 @@ | |||
2275 | 1203 | self.assertTrue(foo1) | 1202 | self.assertTrue(foo1) |
2276 | 1204 | self.assertTrue(foo2) | 1203 | self.assertTrue(foo2) |
2277 | 1205 | self.assertTrue(bar) | 1204 | self.assertTrue(bar) |
2279 | 1206 | self.assertEqual(self.store.find(Foo, title=u"Title 20").cached(), | 1205 | self.assertEqual(self.store.find(Foo, title="Title 20").cached(), |
2280 | 1207 | [foo2]) | 1206 | [foo2]) |
2281 | 1208 | 1207 | ||
2282 | 1209 | def test_find_cached_invalidated(self): | 1208 | def test_find_cached_invalidated(self): |
2283 | @@ -1217,7 +1216,7 @@ | |||
2284 | 1217 | self.store.invalidate(foo) | 1216 | self.store.invalidate(foo) |
2285 | 1218 | # Do not look for the primary key (id), since it's able to get | 1217 | # Do not look for the primary key (id), since it's able to get |
2286 | 1219 | # it without touching the database. Use the title instead. | 1218 | # it without touching the database. Use the title instead. |
2288 | 1220 | self.assertEqual(self.store.find(Foo, title=u"Title 20").cached(), []) | 1219 | self.assertEqual(self.store.find(Foo, title="Title 20").cached(), []) |
2289 | 1221 | 1220 | ||
2290 | 1222 | def test_find_cached_with_info_alive_and_object_dead(self): | 1221 | def test_find_cached_with_info_alive_and_object_dead(self): |
2291 | 1223 | # Disable the cache, which holds strong references. | 1222 | # Disable the cache, which holds strong references. |
2292 | @@ -1242,8 +1241,8 @@ | |||
2293 | 1242 | lst = [bar and (bar.id, bar.title) for bar in result] | 1241 | lst = [bar and (bar.id, bar.title) for bar in result] |
2294 | 1243 | self.assertEqual(lst, [ | 1242 | self.assertEqual(lst, [ |
2295 | 1244 | None, | 1243 | None, |
2298 | 1245 | (200, u"Title 200"), | 1244 | (200, "Title 200"), |
2299 | 1246 | (300, u"Title 100"), | 1245 | (300, "Title 100"), |
2300 | 1247 | ]) | 1246 | ]) |
2301 | 1248 | 1247 | ||
2302 | 1249 | def test_using_find_with_strings(self): | 1248 | def test_using_find_with_strings(self): |
2303 | @@ -1263,8 +1262,8 @@ | |||
2304 | 1263 | lst = [bar and (bar.id, bar.title) for bar in result] | 1262 | lst = [bar and (bar.id, bar.title) for bar in result] |
2305 | 1264 | self.assertEqual(lst, [ | 1263 | self.assertEqual(lst, [ |
2306 | 1265 | None, | 1264 | None, |
2309 | 1266 | (200, u"Title 200"), | 1265 | (200, "Title 200"), |
2310 | 1267 | (300, u"Title 100"), | 1266 | (300, "Title 100"), |
2311 | 1268 | ]) | 1267 | ]) |
2312 | 1269 | 1268 | ||
2313 | 1270 | def test_find_tuple(self): | 1269 | def test_find_tuple(self): |
2314 | @@ -1276,8 +1275,8 @@ | |||
2315 | 1276 | lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title)) | 1275 | lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title)) |
2316 | 1277 | for (foo, bar) in result] | 1276 | for (foo, bar) in result] |
2317 | 1278 | self.assertEqual(lst, [ | 1277 | self.assertEqual(lst, [ |
2320 | 1279 | ((10, u"Title 30"), (100, u"Title 300")), | 1278 | ((10, "Title 30"), (100, "Title 300")), |
2321 | 1280 | ((30, u"Title 10"), (300, u"Title 100")), | 1279 | ((30, "Title 10"), (300, "Title 100")), |
2322 | 1281 | ]) | 1280 | ]) |
2323 | 1282 | 1281 | ||
2324 | 1283 | def test_find_tuple_using(self): | 1282 | def test_find_tuple_using(self): |
2325 | @@ -1289,13 +1288,13 @@ | |||
2326 | 1289 | lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title)) | 1288 | lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title)) |
2327 | 1290 | for (foo, bar) in result] | 1289 | for (foo, bar) in result] |
2328 | 1291 | self.assertEqual(lst, [ | 1290 | self.assertEqual(lst, [ |
2332 | 1292 | ((10, u"Title 30"), (100, u"Title 300")), | 1291 | ((10, "Title 30"), (100, "Title 300")), |
2333 | 1293 | ((20, u"Title 20"), None), | 1292 | ((20, "Title 20"), None), |
2334 | 1294 | ((30, u"Title 10"), (300, u"Title 100")), | 1293 | ((30, "Title 10"), (300, "Title 100")), |
2335 | 1295 | ]) | 1294 | ]) |
2336 | 1296 | 1295 | ||
2337 | 1297 | def test_find_tuple_using_with_disallow_none(self): | 1296 | def test_find_tuple_using_with_disallow_none(self): |
2339 | 1298 | class Bar(object): | 1297 | class Bar: |
2340 | 1299 | __storm_table__ = "bar" | 1298 | __storm_table__ = "bar" |
2341 | 1300 | id = Int(primary=True, allow_none=False) | 1299 | id = Int(primary=True, allow_none=False) |
2342 | 1301 | title = Unicode() | 1300 | title = Unicode() |
2343 | @@ -1310,9 +1309,9 @@ | |||
2344 | 1310 | lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title)) | 1309 | lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title)) |
2345 | 1311 | for (foo, bar) in result] | 1310 | for (foo, bar) in result] |
2346 | 1312 | self.assertEqual(lst, [ | 1311 | self.assertEqual(lst, [ |
2350 | 1313 | ((10, u"Title 30"), (100, u"Title 300")), | 1312 | ((10, "Title 30"), (100, "Title 300")), |
2351 | 1314 | ((20, u"Title 20"), None), | 1313 | ((20, "Title 20"), None), |
2352 | 1315 | ((30, u"Title 10"), (300, u"Title 100")), | 1314 | ((30, "Title 10"), (300, "Title 100")), |
2353 | 1316 | ]) | 1315 | ]) |
2354 | 1317 | 1316 | ||
2355 | 1318 | def test_find_tuple_using_skip_when_none(self): | 1317 | def test_find_tuple_using_skip_when_none(self): |
2356 | @@ -1327,11 +1326,11 @@ | |||
2357 | 1327 | link and (link.bar_id, link.foo_id)) | 1326 | link and (link.bar_id, link.foo_id)) |
2358 | 1328 | for (bar, link) in result] | 1327 | for (bar, link) in result] |
2359 | 1329 | self.assertEqual(lst, [ | 1328 | self.assertEqual(lst, [ |
2362 | 1330 | ((100, u"Title 300"), (100, 10)), | 1329 | ((100, "Title 300"), (100, 10)), |
2363 | 1331 | ((100, u"Title 300"), (100, 20)), | 1330 | ((100, "Title 300"), (100, 20)), |
2364 | 1332 | (None, None), | 1331 | (None, None), |
2367 | 1333 | ((300, u"Title 100"), (300, 10)), | 1332 | ((300, "Title 100"), (300, 10)), |
2368 | 1334 | ((300, u"Title 100"), (300, 30)), | 1333 | ((300, "Title 100"), (300, 30)), |
2369 | 1335 | ]) | 1334 | ]) |
2370 | 1336 | 1335 | ||
2371 | 1337 | def test_find_tuple_contains(self): | 1336 | def test_find_tuple_contains(self): |
2372 | @@ -1362,9 +1361,9 @@ | |||
2373 | 1362 | result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id) | 1361 | result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id) |
2374 | 1363 | foo, bar = result.order_by(Foo.id).any() | 1362 | foo, bar = result.order_by(Foo.id).any() |
2375 | 1364 | self.assertEqual(foo.id, 10) | 1363 | self.assertEqual(foo.id, 10) |
2377 | 1365 | self.assertEqual(foo.title, u"Title 30") | 1364 | self.assertEqual(foo.title, "Title 30") |
2378 | 1366 | self.assertEqual(bar.id, 100) | 1365 | self.assertEqual(bar.id, 100) |
2380 | 1367 | self.assertEqual(bar.title, u"Title 300") | 1366 | self.assertEqual(bar.title, "Title 300") |
2381 | 1368 | 1367 | ||
2382 | 1369 | def test_find_tuple_first(self): | 1368 | def test_find_tuple_first(self): |
2383 | 1370 | bar = self.store.get(Bar, 200) | 1369 | bar = self.store.get(Bar, 200) |
2384 | @@ -1373,9 +1372,9 @@ | |||
2385 | 1373 | result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id) | 1372 | result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id) |
2386 | 1374 | foo, bar = result.order_by(Foo.id).first() | 1373 | foo, bar = result.order_by(Foo.id).first() |
2387 | 1375 | self.assertEqual(foo.id, 10) | 1374 | self.assertEqual(foo.id, 10) |
2389 | 1376 | self.assertEqual(foo.title, u"Title 30") | 1375 | self.assertEqual(foo.title, "Title 30") |
2390 | 1377 | self.assertEqual(bar.id, 100) | 1376 | self.assertEqual(bar.id, 100) |
2392 | 1378 | self.assertEqual(bar.title, u"Title 300") | 1377 | self.assertEqual(bar.title, "Title 300") |
2393 | 1379 | 1378 | ||
2394 | 1380 | def test_find_tuple_last(self): | 1379 | def test_find_tuple_last(self): |
2395 | 1381 | bar = self.store.get(Bar, 200) | 1380 | bar = self.store.get(Bar, 200) |
2396 | @@ -1384,9 +1383,9 @@ | |||
2397 | 1384 | result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id) | 1383 | result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id) |
2398 | 1385 | foo, bar = result.order_by(Foo.id).last() | 1384 | foo, bar = result.order_by(Foo.id).last() |
2399 | 1386 | self.assertEqual(foo.id, 30) | 1385 | self.assertEqual(foo.id, 30) |
2401 | 1387 | self.assertEqual(foo.title, u"Title 10") | 1386 | self.assertEqual(foo.title, "Title 10") |
2402 | 1388 | self.assertEqual(bar.id, 300) | 1387 | self.assertEqual(bar.id, 300) |
2404 | 1389 | self.assertEqual(bar.title, u"Title 100") | 1388 | self.assertEqual(bar.title, "Title 100") |
2405 | 1390 | 1389 | ||
2406 | 1391 | def test_find_tuple_one(self): | 1390 | def test_find_tuple_one(self): |
2407 | 1392 | bar = self.store.get(Bar, 200) | 1391 | bar = self.store.get(Bar, 200) |
2408 | @@ -1396,9 +1395,9 @@ | |||
2409 | 1396 | Bar.foo_id == Foo.id, Foo.id == 10) | 1395 | Bar.foo_id == Foo.id, Foo.id == 10) |
2410 | 1397 | foo, bar = result.order_by(Foo.id).one() | 1396 | foo, bar = result.order_by(Foo.id).one() |
2411 | 1398 | self.assertEqual(foo.id, 10) | 1397 | self.assertEqual(foo.id, 10) |
2413 | 1399 | self.assertEqual(foo.title, u"Title 30") | 1398 | self.assertEqual(foo.title, "Title 30") |
2414 | 1400 | self.assertEqual(bar.id, 100) | 1399 | self.assertEqual(bar.id, 100) |
2416 | 1401 | self.assertEqual(bar.title, u"Title 300") | 1400 | self.assertEqual(bar.title, "Title 300") |
2417 | 1402 | 1401 | ||
2418 | 1403 | def test_find_tuple_count(self): | 1402 | def test_find_tuple_count(self): |
2419 | 1404 | bar = self.store.get(Bar, 200) | 1403 | bar = self.store.get(Bar, 200) |
2420 | @@ -1412,11 +1411,11 @@ | |||
2421 | 1412 | 1411 | ||
2422 | 1413 | def test_find_tuple_set(self): | 1412 | def test_find_tuple_set(self): |
2423 | 1414 | result = self.store.find((Foo, Bar)) | 1413 | result = self.store.find((Foo, Bar)) |
2425 | 1415 | self.assertRaises(FeatureError, result.set, title=u"Title 40") | 1414 | self.assertRaises(FeatureError, result.set, title="Title 40") |
2426 | 1416 | 1415 | ||
2427 | 1417 | def test_find_tuple_kwargs(self): | 1416 | def test_find_tuple_kwargs(self): |
2428 | 1418 | self.assertRaises(FeatureError, | 1417 | self.assertRaises(FeatureError, |
2430 | 1419 | self.store.find, (Foo, Bar), title=u"Title 10") | 1418 | self.store.find, (Foo, Bar), title="Title 10") |
2431 | 1420 | 1419 | ||
2432 | 1421 | def test_find_tuple_cached(self): | 1420 | def test_find_tuple_cached(self): |
2433 | 1422 | result = self.store.find((Foo, Bar)) | 1421 | result = self.store.find((Foo, Bar)) |
2434 | @@ -1429,12 +1428,12 @@ | |||
2435 | 1429 | def test_find_with_expr(self): | 1428 | def test_find_with_expr(self): |
2436 | 1430 | result = self.store.find(Foo.title) | 1429 | result = self.store.find(Foo.title) |
2437 | 1431 | self.assertEqual(sorted(result), | 1430 | self.assertEqual(sorted(result), |
2439 | 1432 | [u"Title 10", u"Title 20", u"Title 30"]) | 1431 | ["Title 10", "Title 20", "Title 30"]) |
2440 | 1433 | 1432 | ||
2441 | 1434 | def test_find_with_expr_uses_variable_set(self): | 1433 | def test_find_with_expr_uses_variable_set(self): |
2442 | 1435 | result = self.store.find(FooVariable.title, | 1434 | result = self.store.find(FooVariable.title, |
2443 | 1436 | FooVariable.id == 10) | 1435 | FooVariable.id == 10) |
2445 | 1437 | self.assertEqual(list(result), [u"to_py(from_db(Title 30))"]) | 1436 | self.assertEqual(list(result), ["to_py(from_db(Title 30))"]) |
2446 | 1438 | 1437 | ||
2447 | 1439 | def test_find_tuple_with_expr(self): | 1438 | def test_find_tuple_with_expr(self): |
2448 | 1440 | result = self.store.find((Foo, Bar.id, Bar.title), | 1439 | result = self.store.find((Foo, Bar.id, Bar.title), |
2449 | @@ -1442,36 +1441,36 @@ | |||
2450 | 1442 | result.order_by(Foo.id) | 1441 | result.order_by(Foo.id) |
2451 | 1443 | self.assertEqual([(foo.id, foo.title, bar_id, bar_title) | 1442 | self.assertEqual([(foo.id, foo.title, bar_id, bar_title) |
2452 | 1444 | for foo, bar_id, bar_title in result], | 1443 | for foo, bar_id, bar_title in result], |
2456 | 1445 | [(10, u"Title 30", 100, u"Title 300"), | 1444 | [(10, "Title 30", 100, "Title 300"), |
2457 | 1446 | (20, u"Title 20", 200, u"Title 200"), | 1445 | (20, "Title 20", 200, "Title 200"), |
2458 | 1447 | (30, u"Title 10", 300, u"Title 100")]) | 1446 | (30, "Title 10", 300, "Title 100")]) |
2459 | 1448 | 1447 | ||
2460 | 1449 | def test_find_using_with_expr(self): | 1448 | def test_find_using_with_expr(self): |
2461 | 1450 | result = self.store.using(Foo).find(Foo.title) | 1449 | result = self.store.using(Foo).find(Foo.title) |
2462 | 1451 | self.assertEqual(sorted(result), | 1450 | self.assertEqual(sorted(result), |
2464 | 1452 | [u"Title 10", u"Title 20", u"Title 30"]) | 1451 | ["Title 10", "Title 20", "Title 30"]) |
2465 | 1453 | 1452 | ||
2466 | 1454 | def test_find_with_expr_contains(self): | 1453 | def test_find_with_expr_contains(self): |
2467 | 1455 | result = self.store.find(Foo.title) | 1454 | result = self.store.find(Foo.title) |
2470 | 1456 | self.assertEqual(u"Title 10" in result, True) | 1455 | self.assertEqual("Title 10" in result, True) |
2471 | 1457 | self.assertEqual(u"Title 42" in result, False) | 1456 | self.assertEqual("Title 42" in result, False) |
2472 | 1458 | 1457 | ||
2473 | 1459 | def test_find_tuple_with_expr_contains(self): | 1458 | def test_find_tuple_with_expr_contains(self): |
2474 | 1460 | foo = self.store.get(Foo, 10) | 1459 | foo = self.store.get(Foo, 10) |
2475 | 1461 | result = self.store.find((Foo, Bar.title), | 1460 | result = self.store.find((Foo, Bar.title), |
2476 | 1462 | Bar.foo_id == Foo.id) | 1461 | Bar.foo_id == Foo.id) |
2479 | 1463 | self.assertEqual((foo, u"Title 300") in result, True) | 1462 | self.assertEqual((foo, "Title 300") in result, True) |
2480 | 1464 | self.assertEqual((foo, u"Title 100") in result, False) | 1463 | self.assertEqual((foo, "Title 100") in result, False) |
2481 | 1465 | 1464 | ||
2482 | 1466 | def test_find_with_expr_contains_with_set_expression(self): | 1465 | def test_find_with_expr_contains_with_set_expression(self): |
2483 | 1467 | result1 = self.store.find(Foo.title) | 1466 | result1 = self.store.find(Foo.title) |
2484 | 1468 | result2 = self.store.find(Foo.title) | 1467 | result2 = self.store.find(Foo.title) |
2486 | 1469 | self.assertEqual(u"Title 10" in result1.union(result2), True) | 1468 | self.assertEqual("Title 10" in result1.union(result2), True) |
2487 | 1470 | 1469 | ||
2488 | 1471 | if self.__class__.__name__.startswith("MySQL"): | 1470 | if self.__class__.__name__.startswith("MySQL"): |
2489 | 1472 | return | 1471 | return |
2492 | 1473 | self.assertEqual(u"Title 10" in result1.intersection(result2), True) | 1472 | self.assertEqual("Title 10" in result1.intersection(result2), True) |
2493 | 1474 | self.assertEqual(u"Title 10" in result1.difference(result2), False) | 1473 | self.assertEqual("Title 10" in result1.difference(result2), False) |
2494 | 1475 | 1474 | ||
2495 | 1476 | def test_find_with_expr_remove_unsupported(self): | 1475 | def test_find_with_expr_remove_unsupported(self): |
2496 | 1477 | result = self.store.find(Foo.title) | 1476 | result = self.store.find(Foo.title) |
2497 | @@ -1492,12 +1491,12 @@ | |||
2498 | 1492 | def test_find_with_expr_values(self): | 1491 | def test_find_with_expr_values(self): |
2499 | 1493 | result = self.store.find(Foo.title) | 1492 | result = self.store.find(Foo.title) |
2500 | 1494 | self.assertEqual(sorted(result.values(Foo.title)), | 1493 | self.assertEqual(sorted(result.values(Foo.title)), |
2502 | 1495 | [u"Title 10", u"Title 20", u"Title 30"]) | 1494 | ["Title 10", "Title 20", "Title 30"]) |
2503 | 1496 | 1495 | ||
2504 | 1497 | def test_find_tuple_with_expr_values(self): | 1496 | def test_find_tuple_with_expr_values(self): |
2505 | 1498 | result = self.store.find((Foo, Bar.title), Bar.foo_id == Foo.id) | 1497 | result = self.store.find((Foo, Bar.title), Bar.foo_id == Foo.id) |
2506 | 1499 | self.assertEqual(sorted(result.values(Foo.title)), | 1498 | self.assertEqual(sorted(result.values(Foo.title)), |
2508 | 1500 | [u"Title 10", u"Title 20", u"Title 30"]) | 1499 | ["Title 10", "Title 20", "Title 30"]) |
2509 | 1501 | 1500 | ||
2510 | 1502 | def test_find_with_expr_set_unsupported(self): | 1501 | def test_find_with_expr_set_unsupported(self): |
2511 | 1503 | result = self.store.find(Foo.title) | 1502 | result = self.store.find(Foo.title) |
2512 | @@ -1520,7 +1519,7 @@ | |||
2513 | 1520 | result2 = self.store.find(Foo.title, Foo.id != 10) | 1519 | result2 = self.store.find(Foo.title, Foo.id != 10) |
2514 | 1521 | result = result1.union(result2) | 1520 | result = result1.union(result2) |
2515 | 1522 | self.assertEqual(sorted(result), | 1521 | self.assertEqual(sorted(result), |
2517 | 1523 | [u"Title 10", u"Title 20", u"Title 30",]) | 1522 | ["Title 10", "Title 20", "Title 30",]) |
2518 | 1524 | 1523 | ||
2519 | 1525 | def test_find_with_expr_union_mismatch(self): | 1524 | def test_find_with_expr_union_mismatch(self): |
2520 | 1526 | result1 = self.store.find(Foo.title) | 1525 | result1 = self.store.find(Foo.title) |
2521 | @@ -1529,19 +1528,19 @@ | |||
2522 | 1529 | 1528 | ||
2523 | 1530 | def test_find_tuple_with_expr_union(self): | 1529 | def test_find_tuple_with_expr_union(self): |
2524 | 1531 | result1 = self.store.find( | 1530 | result1 = self.store.find( |
2526 | 1532 | (Foo, Bar.title), Bar.foo_id == Foo.id, Bar.title == u"Title 100") | 1531 | (Foo, Bar.title), Bar.foo_id == Foo.id, Bar.title == "Title 100") |
2527 | 1533 | result2 = self.store.find( | 1532 | result2 = self.store.find( |
2529 | 1534 | (Foo, Bar.title), Bar.foo_id == Foo.id, Bar.title == u"Title 200") | 1533 | (Foo, Bar.title), Bar.foo_id == Foo.id, Bar.title == "Title 200") |
2530 | 1535 | result = result1.union(result2) | 1534 | result = result1.union(result2) |
2531 | 1536 | self.assertEqual(sorted((foo.id, title) for (foo, title) in result), | 1535 | self.assertEqual(sorted((foo.id, title) for (foo, title) in result), |
2533 | 1537 | [(20, u"Title 200"), (30, u"Title 100")]) | 1536 | [(20, "Title 200"), (30, "Title 100")]) |
2534 | 1538 | 1537 | ||
2535 | 1539 | def test_get_does_not_validate(self): | 1538 | def test_get_does_not_validate(self): |
2536 | 1540 | def validator(object, attr, value): | 1539 | def validator(object, attr, value): |
2537 | 1541 | self.fail("validator called with arguments (%r, %r, %r)" % | 1540 | self.fail("validator called with arguments (%r, %r, %r)" % |
2538 | 1542 | (object, attr, value)) | 1541 | (object, attr, value)) |
2539 | 1543 | 1542 | ||
2541 | 1544 | class Foo(object): | 1543 | class Foo: |
2542 | 1545 | __storm_table__ = "foo" | 1544 | __storm_table__ = "foo" |
2543 | 1546 | id = Int(primary=True) | 1545 | id = Int(primary=True) |
2544 | 1547 | title = Unicode(validator=validator) | 1546 | title = Unicode(validator=validator) |
2545 | @@ -1554,10 +1553,10 @@ | |||
2546 | 1554 | self.fail("validator called with arguments (%r, %r, %r)" % | 1553 | self.fail("validator called with arguments (%r, %r, %r)" % |
2547 | 1555 | (object, attr, value)) | 1554 | (object, attr, value)) |
2548 | 1556 | 1555 | ||
2550 | 1557 | class Foo(object): | 1556 | class Foo: |
2551 | 1558 | __storm_table__ = "foo" | 1557 | __storm_table__ = "foo" |
2552 | 1559 | id = Int(primary=True) | 1558 | id = Int(primary=True) |
2554 | 1560 | title = Unicode(validator=validator, default=u"default value") | 1559 | title = Unicode(validator=validator, default="default value") |
2555 | 1561 | 1560 | ||
2556 | 1562 | foo = self.store.get(Foo, 10) | 1561 | foo = self.store.get(Foo, 10) |
2557 | 1563 | self.assertEqual(foo.title, "Title 30") | 1562 | self.assertEqual(foo.title, "Title 30") |
2558 | @@ -1567,7 +1566,7 @@ | |||
2559 | 1567 | self.fail("validator called with arguments (%r, %r, %r)" % | 1566 | self.fail("validator called with arguments (%r, %r, %r)" % |
2560 | 1568 | (object, attr, value)) | 1567 | (object, attr, value)) |
2561 | 1569 | 1568 | ||
2563 | 1570 | class Foo(object): | 1569 | class Foo: |
2564 | 1571 | __storm_table__ = "foo" | 1570 | __storm_table__ = "foo" |
2565 | 1572 | id = Int(primary=True) | 1571 | id = Int(primary=True) |
2566 | 1573 | title = Unicode(validator=validator) | 1572 | title = Unicode(validator=validator) |
2567 | @@ -1682,7 +1681,7 @@ | |||
2568 | 1682 | result.group_by(Foo) | 1681 | result.group_by(Foo) |
2569 | 1683 | result.order_by(Foo.title) | 1682 | result.order_by(Foo.title) |
2570 | 1684 | result = list(result.values(Foo.title)) | 1683 | result = list(result.values(Foo.title)) |
2572 | 1685 | self.assertEqual(result, [u'Title 20', u'Title 30']) | 1684 | self.assertEqual(result, ['Title 20', 'Title 30']) |
2573 | 1686 | 1685 | ||
2574 | 1687 | def test_find_group_by_union(self): | 1686 | def test_find_group_by_union(self): |
2575 | 1688 | result1 = self.store.find(Foo, id=30) | 1687 | result1 = self.store.find(Foo, id=30) |
2576 | @@ -1703,7 +1702,7 @@ | |||
2577 | 1703 | def test_add_commit(self): | 1702 | def test_add_commit(self): |
2578 | 1704 | foo = Foo() | 1703 | foo = Foo() |
2579 | 1705 | foo.id = 40 | 1704 | foo.id = 40 |
2581 | 1706 | foo.title = u"Title 40" | 1705 | foo.title = "Title 40" |
2582 | 1707 | 1706 | ||
2583 | 1708 | self.store.add(foo) | 1707 | self.store.add(foo) |
2584 | 1709 | 1708 | ||
2585 | @@ -1725,7 +1724,7 @@ | |||
2586 | 1725 | def test_add_rollback_commit(self): | 1724 | def test_add_rollback_commit(self): |
2587 | 1726 | foo = Foo() | 1725 | foo = Foo() |
2588 | 1727 | foo.id = 40 | 1726 | foo.id = 40 |
2590 | 1728 | foo.title = u"Title 40" | 1727 | foo.title = "Title 40" |
2591 | 1729 | 1728 | ||
2592 | 1730 | self.store.add(foo) | 1729 | self.store.add(foo) |
2593 | 1731 | self.store.rollback() | 1730 | self.store.rollback() |
2594 | @@ -1749,7 +1748,7 @@ | |||
2595 | 1749 | def test_add_get(self): | 1748 | def test_add_get(self): |
2596 | 1750 | foo = Foo() | 1749 | foo = Foo() |
2597 | 1751 | foo.id = 40 | 1750 | foo.id = 40 |
2599 | 1752 | foo.title = u"Title 40" | 1751 | foo.title = "Title 40" |
2600 | 1753 | 1752 | ||
2601 | 1754 | self.store.add(foo) | 1753 | self.store.add(foo) |
2602 | 1755 | 1754 | ||
2603 | @@ -1765,7 +1764,7 @@ | |||
2604 | 1765 | def test_add_find(self): | 1764 | def test_add_find(self): |
2605 | 1766 | foo = Foo() | 1765 | foo = Foo() |
2606 | 1767 | foo.id = 40 | 1766 | foo.id = 40 |
2608 | 1768 | foo.title = u"Title 40" | 1767 | foo.title = "Title 40" |
2609 | 1769 | 1768 | ||
2610 | 1770 | self.store.add(foo) | 1769 | self.store.add(foo) |
2611 | 1771 | 1770 | ||
2612 | @@ -1799,7 +1798,7 @@ | |||
2613 | 1799 | self.store.add(bar) | 1798 | self.store.add(bar) |
2614 | 1800 | 1799 | ||
2615 | 1801 | bar.id = 400 | 1800 | bar.id = 400 |
2617 | 1802 | bar.title = u"Title 400" | 1801 | bar.title = "Title 400" |
2618 | 1803 | bar.foo_id = 40 | 1802 | bar.foo_id = 40 |
2619 | 1804 | 1803 | ||
2620 | 1805 | self.store.flush() | 1804 | self.store.flush() |
2621 | @@ -1817,7 +1816,7 @@ | |||
2622 | 1817 | self.store.add(foo) | 1816 | self.store.add(foo) |
2623 | 1818 | self.store.flush() | 1817 | self.store.flush() |
2624 | 1819 | self.assertEqual(type(foo.id), int) | 1818 | self.assertEqual(type(foo.id), int) |
2626 | 1820 | self.assertEqual(foo.title, u"Default Title") | 1819 | self.assertEqual(foo.title, "Default Title") |
2627 | 1821 | 1820 | ||
2628 | 1822 | def test_add_uuid(self): | 1821 | def test_add_uuid(self): |
2629 | 1823 | unique_id = self.store.add(UniqueID(uuid4())) | 1822 | unique_id = self.store.add(UniqueID(uuid4())) |
2630 | @@ -1854,7 +1853,7 @@ | |||
2631 | 1854 | self.store.remove(foo) | 1853 | self.store.remove(foo) |
2632 | 1855 | self.store.rollback() | 1854 | self.store.rollback() |
2633 | 1856 | 1855 | ||
2635 | 1857 | foo.title = u"Title 200" | 1856 | foo.title = "Title 200" |
2636 | 1858 | 1857 | ||
2637 | 1859 | self.store.flush() | 1858 | self.store.flush() |
2638 | 1860 | 1859 | ||
2639 | @@ -1871,7 +1870,7 @@ | |||
2640 | 1871 | self.store.flush() | 1870 | self.store.flush() |
2641 | 1872 | self.store.rollback() | 1871 | self.store.rollback() |
2642 | 1873 | 1872 | ||
2644 | 1874 | foo.title = u"Title 200" | 1873 | foo.title = "Title 200" |
2645 | 1875 | 1874 | ||
2646 | 1876 | self.store.flush() | 1875 | self.store.flush() |
2647 | 1877 | 1876 | ||
2648 | @@ -1887,7 +1886,7 @@ | |||
2649 | 1887 | self.store.remove(foo) | 1886 | self.store.remove(foo) |
2650 | 1888 | self.store.add(foo) | 1887 | self.store.add(foo) |
2651 | 1889 | 1888 | ||
2653 | 1890 | foo.title = u"Title 200" | 1889 | foo.title = "Title 200" |
2654 | 1891 | 1890 | ||
2655 | 1892 | self.store.flush() | 1891 | self.store.flush() |
2656 | 1893 | 1892 | ||
2657 | @@ -1904,7 +1903,7 @@ | |||
2658 | 1904 | self.store.flush() | 1903 | self.store.flush() |
2659 | 1905 | self.store.add(foo) | 1904 | self.store.add(foo) |
2660 | 1906 | 1905 | ||
2662 | 1907 | foo.title = u"Title 200" | 1906 | foo.title = "Title 200" |
2663 | 1908 | 1907 | ||
2664 | 1909 | self.store.flush() | 1908 | self.store.flush() |
2665 | 1910 | 1909 | ||
2666 | @@ -1933,7 +1932,7 @@ | |||
2667 | 1933 | self.store.remove(foo) | 1932 | self.store.remove(foo) |
2668 | 1934 | self.store.flush() | 1933 | self.store.flush() |
2669 | 1935 | 1934 | ||
2671 | 1936 | foo.title = u"Title 200" | 1935 | foo.title = "Title 200" |
2672 | 1937 | 1936 | ||
2673 | 1938 | self.assertTrue(obj_info not in self.store._dirty) | 1937 | self.assertTrue(obj_info not in self.store._dirty) |
2674 | 1939 | 1938 | ||
2675 | @@ -1957,7 +1956,7 @@ | |||
2676 | 1957 | def test_add_rollback_not_in_store(self): | 1956 | def test_add_rollback_not_in_store(self): |
2677 | 1958 | foo = Foo() | 1957 | foo = Foo() |
2678 | 1959 | foo.id = 40 | 1958 | foo.id = 40 |
2680 | 1960 | foo.title = u"Title 40" | 1959 | foo.title = "Title 40" |
2681 | 1961 | 1960 | ||
2682 | 1962 | self.store.add(foo) | 1961 | self.store.add(foo) |
2683 | 1963 | self.store.rollback() | 1962 | self.store.rollback() |
2684 | @@ -1966,7 +1965,7 @@ | |||
2685 | 1966 | 1965 | ||
2686 | 1967 | def test_update_flush_commit(self): | 1966 | def test_update_flush_commit(self): |
2687 | 1968 | foo = self.store.get(Foo, 20) | 1967 | foo = self.store.get(Foo, 20) |
2689 | 1969 | foo.title = u"Title 200" | 1968 | foo.title = "Title 200" |
2690 | 1970 | 1969 | ||
2691 | 1971 | self.assertEqual(self.get_items(), [ | 1970 | self.assertEqual(self.get_items(), [ |
2692 | 1972 | (10, "Title 30"), | 1971 | (10, "Title 30"), |
2693 | @@ -2002,7 +2001,7 @@ | |||
2694 | 2002 | 2001 | ||
2695 | 2003 | def test_update_flush_reload_rollback(self): | 2002 | def test_update_flush_reload_rollback(self): |
2696 | 2004 | foo = self.store.get(Foo, 20) | 2003 | foo = self.store.get(Foo, 20) |
2698 | 2005 | foo.title = u"Title 200" | 2004 | foo.title = "Title 200" |
2699 | 2006 | self.store.flush() | 2005 | self.store.flush() |
2700 | 2007 | self.store.reload(foo) | 2006 | self.store.reload(foo) |
2701 | 2008 | self.store.rollback() | 2007 | self.store.rollback() |
2702 | @@ -2010,7 +2009,7 @@ | |||
2703 | 2010 | 2009 | ||
2704 | 2011 | def test_update_commit(self): | 2010 | def test_update_commit(self): |
2705 | 2012 | foo = self.store.get(Foo, 20) | 2011 | foo = self.store.get(Foo, 20) |
2707 | 2013 | foo.title = u"Title 200" | 2012 | foo.title = "Title 200" |
2708 | 2014 | 2013 | ||
2709 | 2015 | self.store.commit() | 2014 | self.store.commit() |
2710 | 2016 | 2015 | ||
2711 | @@ -2022,9 +2021,9 @@ | |||
2712 | 2022 | 2021 | ||
2713 | 2023 | def test_update_commit_twice(self): | 2022 | def test_update_commit_twice(self): |
2714 | 2024 | foo = self.store.get(Foo, 20) | 2023 | foo = self.store.get(Foo, 20) |
2716 | 2025 | foo.title = u"Title 200" | 2024 | foo.title = "Title 200" |
2717 | 2026 | self.store.commit() | 2025 | self.store.commit() |
2719 | 2027 | foo.title = u"Title 2000" | 2026 | foo.title = "Title 2000" |
2720 | 2028 | self.store.commit() | 2027 | self.store.commit() |
2721 | 2029 | 2028 | ||
2722 | 2030 | self.assertEqual(self.get_committed_items(), [ | 2029 | self.assertEqual(self.get_committed_items(), [ |
2723 | @@ -2035,7 +2034,7 @@ | |||
2724 | 2035 | 2034 | ||
2725 | 2036 | def test_update_checkpoints(self): | 2035 | def test_update_checkpoints(self): |
2726 | 2037 | bar = self.store.get(Bar, 200) | 2036 | bar = self.store.get(Bar, 200) |
2728 | 2038 | bar.title = u"Title 400" | 2037 | bar.title = "Title 400" |
2729 | 2039 | self.store.flush() | 2038 | self.store.flush() |
2730 | 2040 | self.store.execute("UPDATE bar SET title='Title 500' " | 2039 | self.store.execute("UPDATE bar SET title='Title 500' " |
2731 | 2041 | "WHERE id=200") | 2040 | "WHERE id=200") |
2732 | @@ -2099,7 +2098,7 @@ | |||
2733 | 2099 | 2098 | ||
2734 | 2100 | def test_wb_update_not_dirty_after_flush(self): | 2099 | def test_wb_update_not_dirty_after_flush(self): |
2735 | 2101 | foo = self.store.get(Foo, 20) | 2100 | foo = self.store.get(Foo, 20) |
2737 | 2102 | foo.title = u"Title 200" | 2101 | foo.title = "Title 200" |
2738 | 2103 | 2102 | ||
2739 | 2104 | self.store.flush() | 2103 | self.store.flush() |
2740 | 2105 | 2104 | ||
2741 | @@ -2108,7 +2107,7 @@ | |||
2742 | 2108 | 2107 | ||
2743 | 2109 | self.store._disable_change_notification(get_obj_info(foo)) | 2108 | self.store._disable_change_notification(get_obj_info(foo)) |
2744 | 2110 | 2109 | ||
2746 | 2111 | foo.title = u"Title 2000" | 2110 | foo.title = "Title 2000" |
2747 | 2112 | 2111 | ||
2748 | 2113 | self.store.flush() | 2112 | self.store.flush() |
2749 | 2114 | 2113 | ||
2750 | @@ -2120,9 +2119,9 @@ | |||
2751 | 2120 | 2119 | ||
2752 | 2121 | def test_update_find(self): | 2120 | def test_update_find(self): |
2753 | 2122 | foo = self.store.get(Foo, 20) | 2121 | foo = self.store.get(Foo, 20) |
2755 | 2123 | foo.title = u"Title 200" | 2122 | foo.title = "Title 200" |
2756 | 2124 | 2123 | ||
2758 | 2125 | result = self.store.find(Foo, Foo.title == u"Title 200") | 2124 | result = self.store.find(Foo, Foo.title == "Title 200") |
2759 | 2126 | 2125 | ||
2760 | 2127 | self.assertTrue(result.one() is foo) | 2126 | self.assertTrue(result.one() is foo) |
2761 | 2128 | 2127 | ||
2762 | @@ -2135,11 +2134,11 @@ | |||
2763 | 2135 | def test_add_update(self): | 2134 | def test_add_update(self): |
2764 | 2136 | foo = Foo() | 2135 | foo = Foo() |
2765 | 2137 | foo.id = 40 | 2136 | foo.id = 40 |
2767 | 2138 | foo.title = u"Title 40" | 2137 | foo.title = "Title 40" |
2768 | 2139 | 2138 | ||
2769 | 2140 | self.store.add(foo) | 2139 | self.store.add(foo) |
2770 | 2141 | 2140 | ||
2772 | 2142 | foo.title = u"Title 400" | 2141 | foo.title = "Title 400" |
2773 | 2143 | 2142 | ||
2774 | 2144 | self.store.flush() | 2143 | self.store.flush() |
2775 | 2145 | 2144 | ||
2776 | @@ -2153,14 +2152,14 @@ | |||
2777 | 2153 | def test_add_remove_add(self): | 2152 | def test_add_remove_add(self): |
2778 | 2154 | foo = Foo() | 2153 | foo = Foo() |
2779 | 2155 | foo.id = 40 | 2154 | foo.id = 40 |
2781 | 2156 | foo.title = u"Title 40" | 2155 | foo.title = "Title 40" |
2782 | 2157 | 2156 | ||
2783 | 2158 | self.store.add(foo) | 2157 | self.store.add(foo) |
2784 | 2159 | self.store.remove(foo) | 2158 | self.store.remove(foo) |
2785 | 2160 | 2159 | ||
2786 | 2161 | self.assertEqual(Store.of(foo), None) | 2160 | self.assertEqual(Store.of(foo), None) |
2787 | 2162 | 2161 | ||
2789 | 2163 | foo.title = u"Title 400" | 2162 | foo.title = "Title 400" |
2790 | 2164 | 2163 | ||
2791 | 2165 | self.store.add(foo) | 2164 | self.store.add(foo) |
2792 | 2166 | 2165 | ||
2793 | @@ -2192,7 +2191,7 @@ | |||
2794 | 2192 | 2191 | ||
2795 | 2193 | def test_wb_update_remove_add(self): | 2192 | def test_wb_update_remove_add(self): |
2796 | 2194 | foo = self.store.get(Foo, 20) | 2193 | foo = self.store.get(Foo, 20) |
2798 | 2195 | foo.title = u"Title 200" | 2194 | foo.title = "Title 200" |
2799 | 2196 | 2195 | ||
2800 | 2197 | obj_info = get_obj_info(foo) | 2196 | obj_info = get_obj_info(foo) |
2801 | 2198 | 2197 | ||
2802 | @@ -2246,14 +2245,14 @@ | |||
2803 | 2246 | 2245 | ||
2804 | 2247 | def test_join(self): | 2246 | def test_join(self): |
2805 | 2248 | 2247 | ||
2807 | 2249 | class Bar(object): | 2248 | class Bar: |
2808 | 2250 | __storm_table__ = "bar" | 2249 | __storm_table__ = "bar" |
2809 | 2251 | id = Int(primary=True) | 2250 | id = Int(primary=True) |
2810 | 2252 | title = Unicode() | 2251 | title = Unicode() |
2811 | 2253 | 2252 | ||
2812 | 2254 | bar = Bar() | 2253 | bar = Bar() |
2813 | 2255 | bar.id = 40 | 2254 | bar.id = 40 |
2815 | 2256 | bar.title = u"Title 20" | 2255 | bar.title = "Title 20" |
2816 | 2257 | 2256 | ||
2817 | 2258 | self.store.add(bar) | 2257 | self.store.add(bar) |
2818 | 2259 | 2258 | ||
2819 | @@ -2262,7 +2261,7 @@ | |||
2820 | 2262 | 2261 | ||
2821 | 2263 | bar = Bar() | 2262 | bar = Bar() |
2822 | 2264 | bar.id = 400 | 2263 | bar.id = 400 |
2824 | 2265 | bar.title = u"Title 20" | 2264 | bar.title = "Title 20" |
2825 | 2266 | 2265 | ||
2826 | 2267 | self.store.add(bar) | 2266 | self.store.add(bar) |
2827 | 2268 | 2267 | ||
2828 | @@ -2275,14 +2274,14 @@ | |||
2829 | 2275 | 2274 | ||
2830 | 2276 | def test_join_distinct(self): | 2275 | def test_join_distinct(self): |
2831 | 2277 | 2276 | ||
2833 | 2278 | class Bar(object): | 2277 | class Bar: |
2834 | 2279 | __storm_table__ = "bar" | 2278 | __storm_table__ = "bar" |
2835 | 2280 | id = Int(primary=True) | 2279 | id = Int(primary=True) |
2836 | 2281 | title = Unicode() | 2280 | title = Unicode() |
2837 | 2282 | 2281 | ||
2838 | 2283 | bar = Bar() | 2282 | bar = Bar() |
2839 | 2284 | bar.id = 40 | 2283 | bar.id = 40 |
2841 | 2285 | bar.title = u"Title 20" | 2284 | bar.title = "Title 20" |
2842 | 2286 | 2285 | ||
2843 | 2287 | self.store.add(bar) | 2286 | self.store.add(bar) |
2844 | 2288 | 2287 | ||
2845 | @@ -2291,7 +2290,7 @@ | |||
2846 | 2291 | 2290 | ||
2847 | 2292 | bar = Bar() | 2291 | bar = Bar() |
2848 | 2293 | bar.id = 400 | 2292 | bar.id = 400 |
2850 | 2294 | bar.title = u"Title 20" | 2293 | bar.title = "Title 20" |
2851 | 2295 | 2294 | ||
2852 | 2296 | self.store.add(bar) | 2295 | self.store.add(bar) |
2853 | 2297 | 2296 | ||
2854 | @@ -2330,7 +2329,7 @@ | |||
2855 | 2330 | 2329 | ||
2856 | 2331 | foo = Foo() | 2330 | foo = Foo() |
2857 | 2332 | foo.id = 20 | 2331 | foo.id = 20 |
2859 | 2333 | foo.title = u"Readded" | 2332 | foo.title = "Readded" |
2860 | 2334 | self.store.add(foo) | 2333 | self.store.add(foo) |
2861 | 2335 | 2334 | ||
2862 | 2336 | self.store.commit() | 2335 | self.store.commit() |
2863 | @@ -2346,7 +2345,7 @@ | |||
2864 | 2346 | loaded.append("NO!") | 2345 | loaded.append("NO!") |
2865 | 2347 | def __storm_loaded__(self): | 2346 | def __storm_loaded__(self): |
2866 | 2348 | loaded.append((self.id, self.title)) | 2347 | loaded.append((self.id, self.title)) |
2868 | 2349 | self.title = u"Title 200" | 2348 | self.title = "Title 200" |
2869 | 2350 | self.some_attribute = 1 | 2349 | self.some_attribute = 1 |
2870 | 2351 | 2350 | ||
2871 | 2352 | foo = self.store.get(MyFoo, 20) | 2351 | foo = self.store.get(MyFoo, 20) |
2872 | @@ -2376,7 +2375,7 @@ | |||
2873 | 2376 | counter = 0 | 2375 | counter = 0 |
2874 | 2377 | def __storm_pre_flush__(self): | 2376 | def __storm_pre_flush__(self): |
2875 | 2378 | if self.counter == 0: | 2377 | if self.counter == 0: |
2877 | 2379 | self.title = u"Flushing: %s" % self.title | 2378 | self.title = "Flushing: %s" % self.title |
2878 | 2380 | self.counter += 1 | 2379 | self.counter += 1 |
2879 | 2381 | 2380 | ||
2880 | 2382 | foo = self.store.get(MyFoo, 20) | 2381 | foo = self.store.get(MyFoo, 20) |
2881 | @@ -2384,7 +2383,7 @@ | |||
2882 | 2384 | self.assertEqual(foo.title, "Title 20") | 2383 | self.assertEqual(foo.title, "Title 20") |
2883 | 2385 | self.store.flush() | 2384 | self.store.flush() |
2884 | 2386 | self.assertEqual(foo.title, "Title 20") # It wasn't dirty. | 2385 | self.assertEqual(foo.title, "Title 20") # It wasn't dirty. |
2886 | 2387 | foo.title = u"Something" | 2386 | foo.title = "Something" |
2887 | 2388 | self.store.flush() | 2387 | self.store.flush() |
2888 | 2389 | self.assertEqual(foo.title, "Flushing: Something") | 2388 | self.assertEqual(foo.title, "Flushing: Something") |
2889 | 2390 | 2389 | ||
2890 | @@ -2407,11 +2406,11 @@ | |||
2891 | 2407 | class MyFoo(Foo): | 2406 | class MyFoo(Foo): |
2892 | 2408 | def __storm_pre_flush__(self): | 2407 | def __storm_pre_flush__(self): |
2893 | 2409 | other = [foo1, foo2][foo1 is self] | 2408 | other = [foo1, foo2][foo1 is self] |
2895 | 2410 | other.title = u"Changed in hook: " + other.title | 2409 | other.title = "Changed in hook: " + other.title |
2896 | 2411 | 2410 | ||
2897 | 2412 | foo1 = self.store.get(MyFoo, 10) | 2411 | foo1 = self.store.get(MyFoo, 10) |
2898 | 2413 | foo2 = self.store.get(MyFoo, 20) | 2412 | foo2 = self.store.get(MyFoo, 20) |
2900 | 2414 | foo1.title = u"Changed" | 2413 | foo1.title = "Changed" |
2901 | 2415 | self.store.flush() | 2414 | self.store.flush() |
2902 | 2416 | 2415 | ||
2903 | 2417 | self.assertEqual(foo1.title, "Changed in hook: Changed") | 2416 | self.assertEqual(foo1.title, "Changed in hook: Changed") |
2904 | @@ -2424,14 +2423,14 @@ | |||
2905 | 2424 | def __storm_flushed__(self): | 2423 | def __storm_flushed__(self): |
2906 | 2425 | if not self.done: | 2424 | if not self.done: |
2907 | 2426 | self.done = True | 2425 | self.done = True |
2909 | 2427 | self.title = u"Flushed: %s" % self.title | 2426 | self.title = "Flushed: %s" % self.title |
2910 | 2428 | 2427 | ||
2911 | 2429 | foo = self.store.get(MyFoo, 20) | 2428 | foo = self.store.get(MyFoo, 20) |
2912 | 2430 | 2429 | ||
2913 | 2431 | self.assertEqual(foo.title, "Title 20") | 2430 | self.assertEqual(foo.title, "Title 20") |
2914 | 2432 | self.store.flush() | 2431 | self.store.flush() |
2915 | 2433 | self.assertEqual(foo.title, "Title 20") # It wasn't dirty. | 2432 | self.assertEqual(foo.title, "Title 20") # It wasn't dirty. |
2917 | 2434 | foo.title = u"Something" | 2433 | foo.title = "Something" |
2918 | 2435 | self.store.flush() | 2434 | self.store.flush() |
2919 | 2436 | self.assertEqual(foo.title, "Flushed: Something") | 2435 | self.assertEqual(foo.title, "Flushed: Something") |
2920 | 2437 | 2436 | ||
2921 | @@ -2451,7 +2450,7 @@ | |||
2922 | 2451 | 2450 | ||
2923 | 2452 | def test_retrieve_default_primary_key(self): | 2451 | def test_retrieve_default_primary_key(self): |
2924 | 2453 | foo = Foo() | 2452 | foo = Foo() |
2926 | 2454 | foo.title = u"Title 40" | 2453 | foo.title = "Title 40" |
2927 | 2455 | self.store.add(foo) | 2454 | self.store.add(foo) |
2928 | 2456 | self.store.flush() | 2455 | self.store.flush() |
2929 | 2457 | self.assertNotEqual(foo.id, None) | 2456 | self.assertNotEqual(foo.id, None) |
2930 | @@ -2568,13 +2567,13 @@ | |||
2931 | 2568 | def test_reload_new(self): | 2567 | def test_reload_new(self): |
2932 | 2569 | foo = Foo() | 2568 | foo = Foo() |
2933 | 2570 | foo.id = 40 | 2569 | foo.id = 40 |
2935 | 2571 | foo.title = u"Title 40" | 2570 | foo.title = "Title 40" |
2936 | 2572 | self.assertRaises(WrongStoreError, self.store.reload, foo) | 2571 | self.assertRaises(WrongStoreError, self.store.reload, foo) |
2937 | 2573 | 2572 | ||
2938 | 2574 | def test_reload_new_unflushed(self): | 2573 | def test_reload_new_unflushed(self): |
2939 | 2575 | foo = Foo() | 2574 | foo = Foo() |
2940 | 2576 | foo.id = 40 | 2575 | foo.id = 40 |
2942 | 2577 | foo.title = u"Title 40" | 2576 | foo.title = "Title 40" |
2943 | 2578 | self.store.add(foo) | 2577 | self.store.add(foo) |
2944 | 2579 | self.assertRaises(NotFlushedError, self.store.reload, foo) | 2578 | self.assertRaises(NotFlushedError, self.store.reload, foo) |
2945 | 2580 | 2579 | ||
2946 | @@ -2592,43 +2591,43 @@ | |||
2947 | 2592 | def test_wb_reload_not_dirty(self): | 2591 | def test_wb_reload_not_dirty(self): |
2948 | 2593 | foo = self.store.get(Foo, 20) | 2592 | foo = self.store.get(Foo, 20) |
2949 | 2594 | obj_info = get_obj_info(foo) | 2593 | obj_info = get_obj_info(foo) |
2951 | 2595 | foo.title = u"Title 40" | 2594 | foo.title = "Title 40" |
2952 | 2596 | self.store.reload(foo) | 2595 | self.store.reload(foo) |
2953 | 2597 | self.assertTrue(obj_info not in self.store._dirty) | 2596 | self.assertTrue(obj_info not in self.store._dirty) |
2954 | 2598 | 2597 | ||
2955 | 2599 | def test_find_set_empty(self): | 2598 | def test_find_set_empty(self): |
2957 | 2600 | self.store.find(Foo, title=u"Title 20").set() | 2599 | self.store.find(Foo, title="Title 20").set() |
2958 | 2601 | foo = self.store.get(Foo, 20) | 2600 | foo = self.store.get(Foo, 20) |
2959 | 2602 | self.assertEqual(foo.title, "Title 20") | 2601 | self.assertEqual(foo.title, "Title 20") |
2960 | 2603 | 2602 | ||
2961 | 2604 | def test_find_set(self): | 2603 | def test_find_set(self): |
2963 | 2605 | self.store.find(Foo, title=u"Title 20").set(title=u"Title 40") | 2604 | self.store.find(Foo, title="Title 20").set(title="Title 40") |
2964 | 2606 | foo = self.store.get(Foo, 20) | 2605 | foo = self.store.get(Foo, 20) |
2965 | 2607 | self.assertEqual(foo.title, "Title 40") | 2606 | self.assertEqual(foo.title, "Title 40") |
2966 | 2608 | 2607 | ||
2967 | 2609 | def test_find_set_with_func_expr(self): | 2608 | def test_find_set_with_func_expr(self): |
2969 | 2610 | self.store.find(Foo, title=u"Title 20").set(title=Lower(u"Title 40")) | 2609 | self.store.find(Foo, title="Title 20").set(title=Lower("Title 40")) |
2970 | 2611 | foo = self.store.get(Foo, 20) | 2610 | foo = self.store.get(Foo, 20) |
2971 | 2612 | self.assertEqual(foo.title, "title 40") | 2611 | self.assertEqual(foo.title, "title 40") |
2972 | 2613 | 2612 | ||
2973 | 2614 | def test_find_set_equality_with_func_expr(self): | 2613 | def test_find_set_equality_with_func_expr(self): |
2976 | 2615 | self.store.find(Foo, title=u"Title 20").set( | 2614 | self.store.find(Foo, title="Title 20").set( |
2977 | 2616 | Foo.title == Lower(u"Title 40")) | 2615 | Foo.title == Lower("Title 40")) |
2978 | 2617 | foo = self.store.get(Foo, 20) | 2616 | foo = self.store.get(Foo, 20) |
2979 | 2618 | self.assertEqual(foo.title, "title 40") | 2617 | self.assertEqual(foo.title, "title 40") |
2980 | 2619 | 2618 | ||
2981 | 2620 | def test_find_set_column(self): | 2619 | def test_find_set_column(self): |
2983 | 2621 | self.store.find(Bar, title=u"Title 200").set(foo_id=Bar.id) | 2620 | self.store.find(Bar, title="Title 200").set(foo_id=Bar.id) |
2984 | 2622 | bar = self.store.get(Bar, 200) | 2621 | bar = self.store.get(Bar, 200) |
2985 | 2623 | self.assertEqual(bar.foo_id, 200) | 2622 | self.assertEqual(bar.foo_id, 200) |
2986 | 2624 | 2623 | ||
2987 | 2625 | def test_find_set_expr(self): | 2624 | def test_find_set_expr(self): |
2989 | 2626 | self.store.find(Foo, title=u"Title 20").set(Foo.title == u"Title 40") | 2625 | self.store.find(Foo, title="Title 20").set(Foo.title == "Title 40") |
2990 | 2627 | foo = self.store.get(Foo, 20) | 2626 | foo = self.store.get(Foo, 20) |
2991 | 2628 | self.assertEqual(foo.title, "Title 40") | 2627 | self.assertEqual(foo.title, "Title 40") |
2992 | 2629 | 2628 | ||
2993 | 2630 | def test_find_set_none(self): | 2629 | def test_find_set_none(self): |
2995 | 2631 | self.store.find(Foo, title=u"Title 20").set(title=None) | 2630 | self.store.find(Foo, title="Title 20").set(title=None) |
2996 | 2632 | foo = self.store.get(Foo, 20) | 2631 | foo = self.store.get(Foo, 20) |
2997 | 2633 | self.assertEqual(foo.title, None) | 2632 | self.assertEqual(foo.title, None) |
2998 | 2634 | 2633 | ||
2999 | @@ -2653,7 +2652,7 @@ | |||
3000 | 2653 | 2652 | ||
3001 | 2654 | def test_find_set_none_on_cached(self): | 2653 | def test_find_set_none_on_cached(self): |
3002 | 2655 | foo = self.store.get(Foo, 20) | 2654 | foo = self.store.get(Foo, 20) |
3004 | 2656 | self.store.find(Foo, title=u"Title 20").set(title=None) | 2655 | self.store.find(Foo, title="Title 20").set(title=None) |
3005 | 2657 | self.assertEqual(foo.title, None) | 2656 | self.assertEqual(foo.title, None) |
3006 | 2658 | 2657 | ||
3007 | 2659 | def test_find_set_on_cached_but_removed(self): | 2658 | def test_find_set_on_cached_but_removed(self): |
3008 | @@ -2668,27 +2667,27 @@ | |||
3009 | 2668 | foo1 = self.store.get(Foo, 20) | 2667 | foo1 = self.store.get(Foo, 20) |
3010 | 2669 | foo2 = self.store.get(Foo, 30) | 2668 | foo2 = self.store.get(Foo, 30) |
3011 | 2670 | self.store.find( | 2669 | self.store.find( |
3013 | 2671 | Foo, Foo.id == Select(SQL("20"))).set(title=u"Title 40") | 2670 | Foo, Foo.id == Select(SQL("20"))).set(title="Title 40") |
3014 | 2672 | self.assertEqual(foo1.title, "Title 40") | 2671 | self.assertEqual(foo1.title, "Title 40") |
3015 | 2673 | self.assertEqual(foo2.title, "Title 10") | 2672 | self.assertEqual(foo2.title, "Title 10") |
3016 | 2674 | 2673 | ||
3017 | 2675 | def test_find_set_expr_unsupported(self): | 2674 | def test_find_set_expr_unsupported(self): |
3020 | 2676 | result = self.store.find(Foo, title=u"Title 20") | 2675 | result = self.store.find(Foo, title="Title 20") |
3021 | 2677 | self.assertRaises(FeatureError, result.set, Foo.title > u"Title 40") | 2676 | self.assertRaises(FeatureError, result.set, Foo.title > "Title 40") |
3022 | 2678 | 2677 | ||
3023 | 2679 | def test_find_set_expr_unsupported_without_column(self): | 2678 | def test_find_set_expr_unsupported_without_column(self): |
3025 | 2680 | result = self.store.find(Foo, title=u"Title 20") | 2679 | result = self.store.find(Foo, title="Title 20") |
3026 | 2681 | self.assertRaises(FeatureError, result.set, | 2680 | self.assertRaises(FeatureError, result.set, |
3027 | 2682 | Eq(object(), IntVariable(1))) | 2681 | Eq(object(), IntVariable(1))) |
3028 | 2683 | 2682 | ||
3029 | 2684 | def test_find_set_expr_unsupported_without_expr_or_variable(self): | 2683 | def test_find_set_expr_unsupported_without_expr_or_variable(self): |
3031 | 2685 | result = self.store.find(Foo, title=u"Title 20") | 2684 | result = self.store.find(Foo, title="Title 20") |
3032 | 2686 | self.assertRaises(FeatureError, result.set, Eq(Foo.id, object())) | 2685 | self.assertRaises(FeatureError, result.set, Eq(Foo.id, object())) |
3033 | 2687 | 2686 | ||
3034 | 2688 | def test_find_set_expr_unsupported_autoreloads(self): | 2687 | def test_find_set_expr_unsupported_autoreloads(self): |
3035 | 2689 | bar1 = self.store.get(Bar, 200) | 2688 | bar1 = self.store.get(Bar, 200) |
3036 | 2690 | bar2 = self.store.get(Bar, 300) | 2689 | bar2 = self.store.get(Bar, 300) |
3038 | 2691 | self.store.find(Bar, id=Select(SQL("200"))).set(title=u"Title 400") | 2690 | self.store.find(Bar, id=Select(SQL("200"))).set(title="Title 400") |
3039 | 2692 | bar1_vars = get_obj_info(bar1).variables | 2691 | bar1_vars = get_obj_info(bar1).variables |
3040 | 2693 | bar2_vars = get_obj_info(bar2).variables | 2692 | bar2_vars = get_obj_info(bar2).variables |
3041 | 2694 | self.assertEqual(bar1_vars[Bar.title].get_lazy(), AutoReload) | 2693 | self.assertEqual(bar1_vars[Bar.title].get_lazy(), AutoReload) |
3042 | @@ -2707,7 +2706,7 @@ | |||
3043 | 2707 | # column. See Bug #328603 for more info. | 2706 | # column. See Bug #328603 for more info. |
3044 | 2708 | foo1 = self.store.get(Foo, 20) | 2707 | foo1 = self.store.get(Foo, 20) |
3045 | 2709 | bar1 = self.store.get(Bar, 200) | 2708 | bar1 = self.store.get(Bar, 200) |
3047 | 2710 | self.store.find(Bar, id=Select(SQL("200"))).set(title=u"Title 400") | 2709 | self.store.find(Bar, id=Select(SQL("200"))).set(title="Title 400") |
3048 | 2711 | foo1_vars = get_obj_info(foo1).variables | 2710 | foo1_vars = get_obj_info(foo1).variables |
3049 | 2712 | bar1_vars = get_obj_info(bar1).variables | 2711 | bar1_vars = get_obj_info(bar1).variables |
3050 | 2713 | self.assertNotEqual(foo1_vars[Foo.title].get_lazy(), AutoReload) | 2712 | self.assertNotEqual(foo1_vars[Foo.title].get_lazy(), AutoReload) |
3051 | @@ -2741,7 +2740,7 @@ | |||
3052 | 2741 | 2740 | ||
3053 | 2742 | def test_wb_find_set_checkpoints(self): | 2741 | def test_wb_find_set_checkpoints(self): |
3054 | 2743 | bar = self.store.get(Bar, 200) | 2742 | bar = self.store.get(Bar, 200) |
3056 | 2744 | self.store.find(Bar, id=200).set(title=u"Title 400") | 2743 | self.store.find(Bar, id=200).set(title="Title 400") |
3057 | 2745 | self.store._connection.execute("UPDATE bar SET " | 2744 | self.store._connection.execute("UPDATE bar SET " |
3058 | 2746 | "title='Title 500' " | 2745 | "title='Title 500' " |
3059 | 2747 | "WHERE id=200") | 2746 | "WHERE id=200") |
3060 | @@ -2759,7 +2758,7 @@ | |||
3061 | 2759 | obj_info = get_obj_info(foo) | 2758 | obj_info = get_obj_info(foo) |
3062 | 2760 | del foo | 2759 | del foo |
3063 | 2761 | gc.collect() | 2760 | gc.collect() |
3065 | 2762 | self.store.find(Foo, title=u"Title 20").set(title=u"Title 40") | 2761 | self.store.find(Foo, title="Title 20").set(title="Title 40") |
3066 | 2763 | foo = self.store.get(Foo, 20) | 2762 | foo = self.store.get(Foo, 20) |
3067 | 2764 | self.assertFalse(hasattr(foo, "tainted")) | 2763 | self.assertFalse(hasattr(foo, "tainted")) |
3068 | 2765 | self.assertEqual(foo.title, "Title 40") | 2764 | self.assertEqual(foo.title, "Title 40") |
3069 | @@ -2799,7 +2798,7 @@ | |||
3070 | 2799 | """ | 2798 | """ |
3071 | 2800 | self.get_cache(self.store).set_size(0) | 2799 | self.get_cache(self.store).set_size(0) |
3072 | 2801 | bar = self.store.get(Bar, 100) | 2800 | bar = self.store.get(Bar, 100) |
3074 | 2802 | bar.foo.title = u"Changed title" | 2801 | bar.foo.title = "Changed title" |
3075 | 2803 | bar_ref = weakref.ref(get_obj_info(bar)) | 2802 | bar_ref = weakref.ref(get_obj_info(bar)) |
3076 | 2804 | foo = bar.foo | 2803 | foo = bar.foo |
3077 | 2805 | del bar | 2804 | del bar |
3078 | @@ -2817,7 +2816,7 @@ | |||
3079 | 2817 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) | 2816 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) |
3080 | 2818 | 2817 | ||
3081 | 2819 | foo = self.store.get(MyFoo, 10) | 2818 | foo = self.store.get(MyFoo, 10) |
3083 | 2820 | foo.bar.title = u"Changed title" | 2819 | foo.bar.title = "Changed title" |
3084 | 2821 | foo_ref = weakref.ref(get_obj_info(foo)) | 2820 | foo_ref = weakref.ref(get_obj_info(foo)) |
3085 | 2822 | bar = foo.bar | 2821 | bar = foo.bar |
3086 | 2823 | del foo | 2822 | del foo |
3087 | @@ -2830,13 +2829,13 @@ | |||
3088 | 2830 | pass | 2829 | pass |
3089 | 2831 | MyBar.foo = Reference(MyBar.title, Foo.title) | 2830 | MyBar.foo = Reference(MyBar.title, Foo.title) |
3090 | 2832 | bar = self.store.get(MyBar, 100) | 2831 | bar = self.store.get(MyBar, 100) |
3092 | 2833 | bar.title = u"Title 30" | 2832 | bar.title = "Title 30" |
3093 | 2834 | self.store.flush() | 2833 | self.store.flush() |
3094 | 2835 | self.assertEqual(bar.foo.id, 10) | 2834 | self.assertEqual(bar.foo.id, 10) |
3095 | 2836 | bar.foo.title = SQL("'Title 40'") | 2835 | bar.foo.title = SQL("'Title 40'") |
3096 | 2837 | self.assertEqual(bar.foo, None) | 2836 | self.assertEqual(bar.foo, None) |
3099 | 2838 | self.assertEqual(self.store.find(Foo, title=u"Title 30").one(), None) | 2837 | self.assertEqual(self.store.find(Foo, title="Title 30").one(), None) |
3100 | 2839 | self.assertEqual(self.store.get(Foo, 10).title, u"Title 40") | 2838 | self.assertEqual(self.store.get(Foo, 10).title, "Title 40") |
3101 | 2840 | 2839 | ||
3102 | 2841 | def test_reference_on_non_primary_key(self): | 2840 | def test_reference_on_non_primary_key(self): |
3103 | 2842 | self.store.execute("INSERT INTO bar VALUES (400, 40, 'Title 30')") | 2841 | self.store.execute("INSERT INTO bar VALUES (400, 40, 'Title 30')") |
3104 | @@ -2856,7 +2855,7 @@ | |||
3105 | 2856 | def test_new_reference(self): | 2855 | def test_new_reference(self): |
3106 | 2857 | bar = Bar() | 2856 | bar = Bar() |
3107 | 2858 | bar.id = 400 | 2857 | bar.id = 400 |
3109 | 2859 | bar.title = u"Title 400" | 2858 | bar.title = "Title 400" |
3110 | 2860 | bar.foo_id = 10 | 2859 | bar.foo_id = 10 |
3111 | 2861 | 2860 | ||
3112 | 2862 | self.assertEqual(bar.foo, None) | 2861 | self.assertEqual(bar.foo, None) |
3113 | @@ -2895,12 +2894,12 @@ | |||
3114 | 2895 | 2894 | ||
3115 | 2896 | def test_reference_on_added(self): | 2895 | def test_reference_on_added(self): |
3116 | 2897 | foo = Foo() | 2896 | foo = Foo() |
3118 | 2898 | foo.title = u"Title 40" | 2897 | foo.title = "Title 40" |
3119 | 2899 | self.store.add(foo) | 2898 | self.store.add(foo) |
3120 | 2900 | 2899 | ||
3121 | 2901 | bar = Bar() | 2900 | bar = Bar() |
3122 | 2902 | bar.id = 400 | 2901 | bar.id = 400 |
3124 | 2903 | bar.title = u"Title 400" | 2902 | bar.title = "Title 400" |
3125 | 2904 | bar.foo = foo | 2903 | bar.foo = foo |
3126 | 2905 | self.store.add(bar) | 2904 | self.store.add(bar) |
3127 | 2906 | 2905 | ||
3128 | @@ -2920,12 +2919,12 @@ | |||
3129 | 2920 | 2919 | ||
3130 | 2921 | def test_reference_on_added_with_autoreload_key(self): | 2920 | def test_reference_on_added_with_autoreload_key(self): |
3131 | 2922 | foo = Foo() | 2921 | foo = Foo() |
3133 | 2923 | foo.title = u"Title 40" | 2922 | foo.title = "Title 40" |
3134 | 2924 | self.store.add(foo) | 2923 | self.store.add(foo) |
3135 | 2925 | 2924 | ||
3136 | 2926 | bar = Bar() | 2925 | bar = Bar() |
3137 | 2927 | bar.id = 400 | 2926 | bar.id = 400 |
3139 | 2928 | bar.title = u"Title 400" | 2927 | bar.title = "Title 400" |
3140 | 2929 | bar.foo = foo | 2928 | bar.foo = foo |
3141 | 2930 | self.store.add(bar) | 2929 | self.store.add(bar) |
3142 | 2931 | 2930 | ||
3143 | @@ -2952,11 +2951,11 @@ | |||
3144 | 2952 | 2951 | ||
3145 | 2953 | def test_reference_assign_none(self): | 2952 | def test_reference_assign_none(self): |
3146 | 2954 | foo = Foo() | 2953 | foo = Foo() |
3148 | 2955 | foo.title = u"Title 40" | 2954 | foo.title = "Title 40" |
3149 | 2956 | 2955 | ||
3150 | 2957 | bar = Bar() | 2956 | bar = Bar() |
3151 | 2958 | bar.id = 400 | 2957 | bar.id = 400 |
3153 | 2959 | bar.title = u"Title 400" | 2958 | bar.title = "Title 400" |
3154 | 2960 | bar.foo = foo | 2959 | bar.foo = foo |
3155 | 2961 | bar.foo = None | 2960 | bar.foo = None |
3156 | 2962 | bar.foo = None # Twice to make sure it doesn't blow up. | 2961 | bar.foo = None # Twice to make sure it doesn't blow up. |
3157 | @@ -2973,7 +2972,7 @@ | |||
3158 | 2973 | self.assertEqual(bar.foo, None) | 2972 | self.assertEqual(bar.foo, None) |
3159 | 2974 | 2973 | ||
3160 | 2975 | def test_reference_on_added_composed_key(self): | 2974 | def test_reference_on_added_composed_key(self): |
3162 | 2976 | class Bar(object): | 2975 | class Bar: |
3163 | 2977 | __storm_table__ = "bar" | 2976 | __storm_table__ = "bar" |
3164 | 2978 | id = Int(primary=True) | 2977 | id = Int(primary=True) |
3165 | 2979 | foo_id = Int() | 2978 | foo_id = Int() |
3166 | @@ -2981,7 +2980,7 @@ | |||
3167 | 2981 | foo = Reference((foo_id, title), (Foo.id, Foo.title)) | 2980 | foo = Reference((foo_id, title), (Foo.id, Foo.title)) |
3168 | 2982 | 2981 | ||
3169 | 2983 | foo = Foo() | 2982 | foo = Foo() |
3171 | 2984 | foo.title = u"Title 40" | 2983 | foo.title = "Title 40" |
3172 | 2985 | self.store.add(foo) | 2984 | self.store.add(foo) |
3173 | 2986 | 2985 | ||
3174 | 2987 | bar = Bar() | 2986 | bar = Bar() |
3175 | @@ -3004,7 +3003,7 @@ | |||
3176 | 3004 | self.assertEqual(result.get_one(), ("Title 40",)) | 3003 | self.assertEqual(result.get_one(), ("Title 40",)) |
3177 | 3005 | 3004 | ||
3178 | 3006 | def test_reference_assign_composed_remote_key(self): | 3005 | def test_reference_assign_composed_remote_key(self): |
3180 | 3007 | class Bar(object): | 3006 | class Bar: |
3181 | 3008 | __storm_table__ = "bar" | 3007 | __storm_table__ = "bar" |
3182 | 3009 | id = Int(primary=True) | 3008 | id = Int(primary=True) |
3183 | 3010 | foo_id = Int() | 3009 | foo_id = Int() |
3184 | @@ -3013,7 +3012,7 @@ | |||
3185 | 3013 | 3012 | ||
3186 | 3014 | bar = Bar() | 3013 | bar = Bar() |
3187 | 3015 | bar.id = 400 | 3014 | bar.id = 400 |
3189 | 3016 | bar.foo = (20, u"Title 20") | 3015 | bar.foo = (20, "Title 20") |
3190 | 3017 | self.store.add(bar) | 3016 | self.store.add(bar) |
3191 | 3018 | 3017 | ||
3192 | 3019 | self.assertEqual(bar.foo_id, 20) | 3018 | self.assertEqual(bar.foo_id, 20) |
3193 | @@ -3023,13 +3022,13 @@ | |||
3194 | 3023 | 3022 | ||
3195 | 3024 | def test_reference_on_added_unlink_on_flush(self): | 3023 | def test_reference_on_added_unlink_on_flush(self): |
3196 | 3025 | foo = Foo() | 3024 | foo = Foo() |
3198 | 3026 | foo.title = u"Title 40" | 3025 | foo.title = "Title 40" |
3199 | 3027 | self.store.add(foo) | 3026 | self.store.add(foo) |
3200 | 3028 | 3027 | ||
3201 | 3029 | bar = Bar() | 3028 | bar = Bar() |
3202 | 3030 | bar.id = 400 | 3029 | bar.id = 400 |
3203 | 3031 | bar.foo = foo | 3030 | bar.foo = foo |
3205 | 3032 | bar.title = u"Title 400" | 3031 | bar.title = "Title 400" |
3206 | 3033 | self.store.add(bar) | 3032 | self.store.add(bar) |
3207 | 3034 | 3033 | ||
3208 | 3035 | foo.id = 40 | 3034 | foo.id = 40 |
3209 | @@ -3057,15 +3056,15 @@ | |||
3210 | 3057 | 3056 | ||
3211 | 3058 | def test_reference_on_two_added(self): | 3057 | def test_reference_on_two_added(self): |
3212 | 3059 | foo1 = Foo() | 3058 | foo1 = Foo() |
3214 | 3060 | foo1.title = u"Title 40" | 3059 | foo1.title = "Title 40" |
3215 | 3061 | foo2 = Foo() | 3060 | foo2 = Foo() |
3217 | 3062 | foo2.title = u"Title 40" | 3061 | foo2.title = "Title 40" |
3218 | 3063 | self.store.add(foo1) | 3062 | self.store.add(foo1) |
3219 | 3064 | self.store.add(foo2) | 3063 | self.store.add(foo2) |
3220 | 3065 | 3064 | ||
3221 | 3066 | bar = Bar() | 3065 | bar = Bar() |
3222 | 3067 | bar.id = 400 | 3066 | bar.id = 400 |
3224 | 3068 | bar.title = u"Title 400" | 3067 | bar.title = "Title 400" |
3225 | 3069 | bar.foo = foo1 | 3068 | bar.foo = foo1 |
3226 | 3070 | bar.foo = foo2 | 3069 | bar.foo = foo2 |
3227 | 3071 | self.store.add(bar) | 3070 | self.store.add(bar) |
3228 | @@ -3077,12 +3076,12 @@ | |||
3229 | 3077 | 3076 | ||
3230 | 3078 | def test_reference_on_added_and_changed_manually(self): | 3077 | def test_reference_on_added_and_changed_manually(self): |
3231 | 3079 | foo = Foo() | 3078 | foo = Foo() |
3233 | 3080 | foo.title = u"Title 40" | 3079 | foo.title = "Title 40" |
3234 | 3081 | self.store.add(foo) | 3080 | self.store.add(foo) |
3235 | 3082 | 3081 | ||
3236 | 3083 | bar = Bar() | 3082 | bar = Bar() |
3237 | 3084 | bar.id = 400 | 3083 | bar.id = 400 |
3239 | 3085 | bar.title = u"Title 400" | 3084 | bar.title = "Title 400" |
3240 | 3086 | bar.foo = foo | 3085 | bar.foo = foo |
3241 | 3087 | self.store.add(bar) | 3086 | self.store.add(bar) |
3242 | 3088 | 3087 | ||
3243 | @@ -3091,7 +3090,7 @@ | |||
3244 | 3091 | self.assertEqual(bar.foo_id, 40) | 3090 | self.assertEqual(bar.foo_id, 40) |
3245 | 3092 | 3091 | ||
3246 | 3093 | def test_reference_on_added_composed_key_changed_manually(self): | 3092 | def test_reference_on_added_composed_key_changed_manually(self): |
3248 | 3094 | class Bar(object): | 3093 | class Bar: |
3249 | 3095 | __storm_table__ = "bar" | 3094 | __storm_table__ = "bar" |
3250 | 3096 | id = Int(primary=True) | 3095 | id = Int(primary=True) |
3251 | 3097 | foo_id = Int() | 3096 | foo_id = Int() |
3252 | @@ -3099,7 +3098,7 @@ | |||
3253 | 3099 | foo = Reference((foo_id, title), (Foo.id, Foo.title)) | 3098 | foo = Reference((foo_id, title), (Foo.id, Foo.title)) |
3254 | 3100 | 3099 | ||
3255 | 3101 | foo = Foo() | 3100 | foo = Foo() |
3257 | 3102 | foo.title = u"Title 40" | 3101 | foo.title = "Title 40" |
3258 | 3103 | self.store.add(foo) | 3102 | self.store.add(foo) |
3259 | 3104 | 3103 | ||
3260 | 3105 | bar = Bar() | 3104 | bar = Bar() |
3261 | @@ -3107,7 +3106,7 @@ | |||
3262 | 3107 | bar.foo = foo | 3106 | bar.foo = foo |
3263 | 3108 | self.store.add(bar) | 3107 | self.store.add(bar) |
3264 | 3109 | 3108 | ||
3266 | 3110 | bar.title = u"Title 50" | 3109 | bar.title = "Title 50" |
3267 | 3111 | 3110 | ||
3268 | 3112 | self.assertEqual(bar.foo, None) | 3111 | self.assertEqual(bar.foo, None) |
3269 | 3113 | 3112 | ||
3270 | @@ -3117,12 +3116,12 @@ | |||
3271 | 3117 | 3116 | ||
3272 | 3118 | def test_reference_on_added_no_local_store(self): | 3117 | def test_reference_on_added_no_local_store(self): |
3273 | 3119 | foo = Foo() | 3118 | foo = Foo() |
3275 | 3120 | foo.title = u"Title 40" | 3119 | foo.title = "Title 40" |
3276 | 3121 | self.store.add(foo) | 3120 | self.store.add(foo) |
3277 | 3122 | 3121 | ||
3278 | 3123 | bar = Bar() | 3122 | bar = Bar() |
3279 | 3124 | bar.id = 400 | 3123 | bar.id = 400 |
3281 | 3125 | bar.title = u"Title 400" | 3124 | bar.title = "Title 400" |
3282 | 3126 | bar.foo = foo | 3125 | bar.foo = foo |
3283 | 3127 | 3126 | ||
3284 | 3128 | self.assertEqual(Store.of(bar), self.store) | 3127 | self.assertEqual(Store.of(bar), self.store) |
3285 | @@ -3130,11 +3129,11 @@ | |||
3286 | 3130 | 3129 | ||
3287 | 3131 | def test_reference_on_added_no_remote_store(self): | 3130 | def test_reference_on_added_no_remote_store(self): |
3288 | 3132 | foo = Foo() | 3131 | foo = Foo() |
3290 | 3133 | foo.title = u"Title 40" | 3132 | foo.title = "Title 40" |
3291 | 3134 | 3133 | ||
3292 | 3135 | bar = Bar() | 3134 | bar = Bar() |
3293 | 3136 | bar.id = 400 | 3135 | bar.id = 400 |
3295 | 3137 | bar.title = u"Title 400" | 3136 | bar.title = "Title 400" |
3296 | 3138 | self.store.add(bar) | 3137 | self.store.add(bar) |
3297 | 3139 | 3138 | ||
3298 | 3140 | bar.foo = foo | 3139 | bar.foo = foo |
3299 | @@ -3144,11 +3143,11 @@ | |||
3300 | 3144 | 3143 | ||
3301 | 3145 | def test_reference_on_added_no_store(self): | 3144 | def test_reference_on_added_no_store(self): |
3302 | 3146 | foo = Foo() | 3145 | foo = Foo() |
3304 | 3147 | foo.title = u"Title 40" | 3146 | foo.title = "Title 40" |
3305 | 3148 | 3147 | ||
3306 | 3149 | bar = Bar() | 3148 | bar = Bar() |
3307 | 3150 | bar.id = 400 | 3149 | bar.id = 400 |
3309 | 3151 | bar.title = u"Title 400" | 3150 | bar.title = "Title 400" |
3310 | 3152 | bar.foo = foo | 3151 | bar.foo = foo |
3311 | 3153 | 3152 | ||
3312 | 3154 | self.store.add(bar) | 3153 | self.store.add(bar) |
3313 | @@ -3162,11 +3161,11 @@ | |||
3314 | 3162 | 3161 | ||
3315 | 3163 | def test_reference_on_added_no_store_2(self): | 3162 | def test_reference_on_added_no_store_2(self): |
3316 | 3164 | foo = Foo() | 3163 | foo = Foo() |
3318 | 3165 | foo.title = u"Title 40" | 3164 | foo.title = "Title 40" |
3319 | 3166 | 3165 | ||
3320 | 3167 | bar = Bar() | 3166 | bar = Bar() |
3321 | 3168 | bar.id = 400 | 3167 | bar.id = 400 |
3323 | 3169 | bar.title = u"Title 400" | 3168 | bar.title = "Title 400" |
3324 | 3170 | bar.foo = foo | 3169 | bar.foo = foo |
3325 | 3171 | 3170 | ||
3326 | 3172 | self.store.add(foo) | 3171 | self.store.add(foo) |
3327 | @@ -3182,23 +3181,23 @@ | |||
3328 | 3182 | store = self.create_store() | 3181 | store = self.create_store() |
3329 | 3183 | 3182 | ||
3330 | 3184 | foo = Foo() | 3183 | foo = Foo() |
3332 | 3185 | foo.title = u"Title 40" | 3184 | foo.title = "Title 40" |
3333 | 3186 | store.add(foo) | 3185 | store.add(foo) |
3334 | 3187 | 3186 | ||
3335 | 3188 | bar = Bar() | 3187 | bar = Bar() |
3336 | 3189 | bar.id = 400 | 3188 | bar.id = 400 |
3338 | 3190 | bar.title = u"Title 400" | 3189 | bar.title = "Title 400" |
3339 | 3191 | self.store.add(bar) | 3190 | self.store.add(bar) |
3340 | 3192 | 3191 | ||
3341 | 3193 | self.assertRaises(WrongStoreError, setattr, bar, "foo", foo) | 3192 | self.assertRaises(WrongStoreError, setattr, bar, "foo", foo) |
3342 | 3194 | 3193 | ||
3343 | 3195 | def test_reference_on_added_no_store_unlink_before_adding(self): | 3194 | def test_reference_on_added_no_store_unlink_before_adding(self): |
3344 | 3196 | foo1 = Foo() | 3195 | foo1 = Foo() |
3346 | 3197 | foo1.title = u"Title 40" | 3196 | foo1.title = "Title 40" |
3347 | 3198 | 3197 | ||
3348 | 3199 | bar = Bar() | 3198 | bar = Bar() |
3349 | 3200 | bar.id = 400 | 3199 | bar.id = 400 |
3351 | 3201 | bar.title = u"Title 400" | 3200 | bar.title = "Title 400" |
3352 | 3202 | bar.foo = foo1 | 3201 | bar.foo = foo1 |
3353 | 3203 | bar.foo = None | 3202 | bar.foo = None |
3354 | 3204 | 3203 | ||
3355 | @@ -3287,7 +3286,7 @@ | |||
3356 | 3287 | def test_reference_self(self): | 3286 | def test_reference_self(self): |
3357 | 3288 | selfref = self.store.add(SelfRef()) | 3287 | selfref = self.store.add(SelfRef()) |
3358 | 3289 | selfref.id = 400 | 3288 | selfref.id = 400 |
3360 | 3290 | selfref.title = u"Title 400" | 3289 | selfref.title = "Title 400" |
3361 | 3291 | selfref.selfref_id = 25 | 3290 | selfref.selfref_id = 25 |
3362 | 3292 | self.assertEqual(selfref.selfref.id, 25) | 3291 | self.assertEqual(selfref.selfref.id, 25) |
3363 | 3293 | self.assertEqual(selfref.selfref.title, "SelfRef 25") | 3292 | self.assertEqual(selfref.selfref.title, "SelfRef 25") |
3364 | @@ -3300,7 +3299,7 @@ | |||
3365 | 3300 | def test_reference_wont_touch_store_when_key_is_none(self): | 3299 | def test_reference_wont_touch_store_when_key_is_none(self): |
3366 | 3301 | bar = self.store.get(Bar, 200) | 3300 | bar = self.store.get(Bar, 200) |
3367 | 3302 | bar.foo_id = None | 3301 | bar.foo_id = None |
3369 | 3303 | bar.title = u"Don't flush this!" | 3302 | bar.title = "Don't flush this!" |
3370 | 3304 | 3303 | ||
3371 | 3305 | self.assertEqual(bar.foo, None) | 3304 | self.assertEqual(bar.foo, None) |
3372 | 3306 | 3305 | ||
3373 | @@ -3310,7 +3309,7 @@ | |||
3374 | 3310 | def test_reference_wont_touch_store_when_key_is_unset(self): | 3309 | def test_reference_wont_touch_store_when_key_is_unset(self): |
3375 | 3311 | bar = self.store.get(Bar, 200) | 3310 | bar = self.store.get(Bar, 200) |
3376 | 3312 | del bar.foo_id | 3311 | del bar.foo_id |
3378 | 3313 | bar.title = u"Don't flush this!" | 3312 | bar.title = "Don't flush this!" |
3379 | 3314 | 3313 | ||
3380 | 3315 | self.assertEqual(bar.foo, None) | 3314 | self.assertEqual(bar.foo, None) |
3381 | 3316 | 3315 | ||
3382 | @@ -3320,7 +3319,7 @@ | |||
3383 | 3320 | self.assertEqual(result.get_one()[0], "Title 200") | 3319 | self.assertEqual(result.get_one()[0], "Title 200") |
3384 | 3321 | 3320 | ||
3385 | 3322 | def test_reference_wont_touch_store_with_composed_key_none(self): | 3321 | def test_reference_wont_touch_store_with_composed_key_none(self): |
3387 | 3323 | class Bar(object): | 3322 | class Bar: |
3388 | 3324 | __storm_table__ = "bar" | 3323 | __storm_table__ = "bar" |
3389 | 3325 | id = Int(primary=True) | 3324 | id = Int(primary=True) |
3390 | 3326 | foo_id = Int() | 3325 | foo_id = Int() |
3391 | @@ -3354,12 +3353,12 @@ | |||
3392 | 3354 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) | 3353 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) |
3393 | 3355 | 3354 | ||
3394 | 3356 | bar = Bar() | 3355 | bar = Bar() |
3396 | 3357 | bar.title = u"Title 400" | 3356 | bar.title = "Title 400" |
3397 | 3358 | self.store.add(bar) | 3357 | self.store.add(bar) |
3398 | 3359 | 3358 | ||
3399 | 3360 | foo = MyFoo() | 3359 | foo = MyFoo() |
3400 | 3361 | foo.bar = bar | 3360 | foo.bar = bar |
3402 | 3362 | foo.title = u"Title 40" | 3361 | foo.title = "Title 40" |
3403 | 3363 | self.store.add(foo) | 3362 | self.store.add(foo) |
3404 | 3364 | 3363 | ||
3405 | 3365 | self.store.flush() | 3364 | self.store.flush() |
3406 | @@ -3378,12 +3377,12 @@ | |||
3407 | 3378 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) | 3377 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) |
3408 | 3379 | 3378 | ||
3409 | 3380 | bar = Bar() | 3379 | bar = Bar() |
3411 | 3381 | bar.title = u"Title 400" | 3380 | bar.title = "Title 400" |
3412 | 3382 | self.store.add(bar) | 3381 | self.store.add(bar) |
3413 | 3383 | 3382 | ||
3414 | 3384 | foo = MyFoo() | 3383 | foo = MyFoo() |
3415 | 3385 | foo.bar = bar | 3384 | foo.bar = bar |
3417 | 3386 | foo.title = u"Title 40" | 3385 | foo.title = "Title 40" |
3418 | 3387 | self.store.add(foo) | 3386 | self.store.add(foo) |
3419 | 3388 | 3387 | ||
3420 | 3389 | foo.id = 40 | 3388 | foo.id = 40 |
3421 | @@ -3437,11 +3436,11 @@ | |||
3422 | 3437 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) | 3436 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) |
3423 | 3438 | 3437 | ||
3424 | 3439 | bar = Bar() | 3438 | bar = Bar() |
3426 | 3440 | bar.title = u"Title 400" | 3439 | bar.title = "Title 400" |
3427 | 3441 | 3440 | ||
3428 | 3442 | foo = MyFoo() | 3441 | foo = MyFoo() |
3429 | 3443 | foo.bar = bar | 3442 | foo.bar = bar |
3431 | 3444 | foo.title = u"Title 40" | 3443 | foo.title = "Title 40" |
3432 | 3445 | 3444 | ||
3433 | 3446 | self.store.add(bar) | 3445 | self.store.add(bar) |
3434 | 3447 | 3446 | ||
3435 | @@ -3457,11 +3456,11 @@ | |||
3436 | 3457 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) | 3456 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) |
3437 | 3458 | 3457 | ||
3438 | 3459 | bar = Bar() | 3458 | bar = Bar() |
3440 | 3460 | bar.title = u"Title 400" | 3459 | bar.title = "Title 400" |
3441 | 3461 | 3460 | ||
3442 | 3462 | foo = MyFoo() | 3461 | foo = MyFoo() |
3443 | 3463 | foo.bar = bar | 3462 | foo.bar = bar |
3445 | 3464 | foo.title = u"Title 40" | 3463 | foo.title = "Title 40" |
3446 | 3465 | 3464 | ||
3447 | 3466 | self.store.add(foo) | 3465 | self.store.add(foo) |
3448 | 3467 | 3466 | ||
3449 | @@ -3477,10 +3476,10 @@ | |||
3450 | 3477 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) | 3476 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) |
3451 | 3478 | 3477 | ||
3452 | 3479 | bar = Bar() | 3478 | bar = Bar() |
3454 | 3480 | bar.title = u"Title 400" | 3479 | bar.title = "Title 400" |
3455 | 3481 | 3480 | ||
3456 | 3482 | foo = MyFoo() | 3481 | foo = MyFoo() |
3458 | 3483 | foo.title = u"Title 40" | 3482 | foo.title = "Title 40" |
3459 | 3484 | foo.bar = bar | 3483 | foo.bar = bar |
3460 | 3485 | 3484 | ||
3461 | 3486 | self.store.add(foo) | 3485 | self.store.add(foo) |
3462 | @@ -3495,10 +3494,10 @@ | |||
3463 | 3495 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) | 3494 | bar = Reference(Foo.id, Bar.foo_id, on_remote=True) |
3464 | 3496 | 3495 | ||
3465 | 3497 | bar = Bar() | 3496 | bar = Bar() |
3467 | 3498 | bar.title = u"Title 400" | 3497 | bar.title = "Title 400" |
3468 | 3499 | 3498 | ||
3469 | 3500 | foo = MyFoo() | 3499 | foo = MyFoo() |
3471 | 3501 | foo.title = u"Title 40" | 3500 | foo.title = "Title 40" |
3472 | 3502 | foo.bar = bar | 3501 | foo.bar = bar |
3473 | 3503 | 3502 | ||
3474 | 3504 | self.store.add(foo) | 3503 | self.store.add(foo) |
3475 | @@ -3673,7 +3672,7 @@ | |||
3476 | 3673 | bar = Bar() | 3672 | bar = Bar() |
3477 | 3674 | bar.id = 400 | 3673 | bar.id = 400 |
3478 | 3675 | bar.foo_id = 20 | 3674 | bar.foo_id = 20 |
3480 | 3676 | bar.title = u"Title 100" | 3675 | bar.title = "Title 100" |
3481 | 3677 | self.store.add(bar) | 3676 | self.store.add(bar) |
3482 | 3678 | 3677 | ||
3483 | 3679 | def test_reference_set(self): | 3678 | def test_reference_set(self): |
3484 | @@ -3718,13 +3717,13 @@ | |||
3485 | 3718 | def test_reference_set_with_added(self): | 3717 | def test_reference_set_with_added(self): |
3486 | 3719 | bar1 = Bar() | 3718 | bar1 = Bar() |
3487 | 3720 | bar1.id = 400 | 3719 | bar1.id = 400 |
3489 | 3721 | bar1.title = u"Title 400" | 3720 | bar1.title = "Title 400" |
3490 | 3722 | bar2 = Bar() | 3721 | bar2 = Bar() |
3491 | 3723 | bar2.id = 500 | 3722 | bar2.id = 500 |
3493 | 3724 | bar2.title = u"Title 500" | 3723 | bar2.title = "Title 500" |
3494 | 3725 | 3724 | ||
3495 | 3726 | foo = FooRefSet() | 3725 | foo = FooRefSet() |
3497 | 3727 | foo.title = u"Title 40" | 3726 | foo.title = "Title 40" |
3498 | 3728 | foo.bars.add(bar1) | 3727 | foo.bars.add(bar1) |
3499 | 3729 | foo.bars.add(bar2) | 3728 | foo.bars.add(bar2) |
3500 | 3730 | 3729 | ||
3501 | @@ -3743,7 +3742,7 @@ | |||
3502 | 3743 | self.add_reference_set_bar_400() | 3742 | self.add_reference_set_bar_400() |
3503 | 3744 | 3743 | ||
3504 | 3745 | bar = self.store.get(Bar, 400) | 3744 | bar = self.store.get(Bar, 400) |
3506 | 3746 | bar.title = u"Title 20" | 3745 | bar.title = "Title 20" |
3507 | 3747 | 3746 | ||
3508 | 3748 | class FooRefSetComposed(Foo): | 3747 | class FooRefSetComposed(Foo): |
3509 | 3749 | bars = ReferenceSet((Foo.id, Foo.title), | 3748 | bars = ReferenceSet((Foo.id, Foo.title), |
3510 | @@ -3760,7 +3759,7 @@ | |||
3511 | 3760 | ]) | 3759 | ]) |
3512 | 3761 | 3760 | ||
3513 | 3762 | bar = self.store.get(Bar, 200) | 3761 | bar = self.store.get(Bar, 200) |
3515 | 3763 | bar.title = u"Title 20" | 3762 | bar.title = "Title 20" |
3516 | 3764 | 3763 | ||
3517 | 3765 | del items[:] | 3764 | del items[:] |
3518 | 3766 | for bar in foo.bars: | 3765 | for bar in foo.bars: |
3519 | @@ -3803,11 +3802,11 @@ | |||
3520 | 3803 | # Notice that there's another item with this title in the base, | 3802 | # Notice that there's another item with this title in the base, |
3521 | 3804 | # which isn't part of the reference. | 3803 | # which isn't part of the reference. |
3522 | 3805 | 3804 | ||
3524 | 3806 | objects = list(foo.bars.find(Bar.title == u"Title 100")) | 3805 | objects = list(foo.bars.find(Bar.title == "Title 100")) |
3525 | 3807 | self.assertEqual(len(objects), 1) | 3806 | self.assertEqual(len(objects), 1) |
3526 | 3808 | self.assertTrue(objects[0] is bar) | 3807 | self.assertTrue(objects[0] is bar) |
3527 | 3809 | 3808 | ||
3529 | 3810 | objects = list(foo.bars.find(title=u"Title 100")) | 3809 | objects = list(foo.bars.find(title="Title 100")) |
3530 | 3811 | self.assertEqual(len(objects), 1) | 3810 | self.assertEqual(len(objects), 1) |
3531 | 3812 | self.assertTrue(objects[0] is bar) | 3811 | self.assertTrue(objects[0] is bar) |
3532 | 3813 | 3812 | ||
3533 | @@ -4048,7 +4047,7 @@ | |||
3534 | 4048 | def test_reference_set_add(self): | 4047 | def test_reference_set_add(self): |
3535 | 4049 | bar = Bar() | 4048 | bar = Bar() |
3536 | 4050 | bar.id = 400 | 4049 | bar.id = 400 |
3538 | 4051 | bar.title = u"Title 100" | 4050 | bar.title = "Title 100" |
3539 | 4052 | 4051 | ||
3540 | 4053 | foo = self.store.get(FooRefSet, 20) | 4052 | foo = self.store.get(FooRefSet, 20) |
3541 | 4054 | foo.bars.add(bar) | 4053 | foo.bars.add(bar) |
3542 | @@ -4059,10 +4058,10 @@ | |||
3543 | 4059 | def test_reference_set_add_no_store(self): | 4058 | def test_reference_set_add_no_store(self): |
3544 | 4060 | bar = Bar() | 4059 | bar = Bar() |
3545 | 4061 | bar.id = 400 | 4060 | bar.id = 400 |
3547 | 4062 | bar.title = u"Title 400" | 4061 | bar.title = "Title 400" |
3548 | 4063 | 4062 | ||
3549 | 4064 | foo = FooRefSet() | 4063 | foo = FooRefSet() |
3551 | 4065 | foo.title = u"Title 40" | 4064 | foo.title = "Title 40" |
3552 | 4066 | foo.bars.add(bar) | 4065 | foo.bars.add(bar) |
3553 | 4067 | 4066 | ||
3554 | 4068 | self.store.add(foo) | 4067 | self.store.add(foo) |
3555 | @@ -4077,10 +4076,10 @@ | |||
3556 | 4077 | def test_reference_set_add_no_store_2(self): | 4076 | def test_reference_set_add_no_store_2(self): |
3557 | 4078 | bar = Bar() | 4077 | bar = Bar() |
3558 | 4079 | bar.id = 400 | 4078 | bar.id = 400 |
3560 | 4080 | bar.title = u"Title 400" | 4079 | bar.title = "Title 400" |
3561 | 4081 | 4080 | ||
3562 | 4082 | foo = FooRefSet() | 4081 | foo = FooRefSet() |
3564 | 4083 | foo.title = u"Title 40" | 4082 | foo.title = "Title 40" |
3565 | 4084 | foo.bars.add(bar) | 4083 | foo.bars.add(bar) |
3566 | 4085 | 4084 | ||
3567 | 4086 | self.store.add(bar) | 4085 | self.store.add(bar) |
3568 | @@ -4095,13 +4094,13 @@ | |||
3569 | 4095 | def test_reference_set_add_no_store_unlink_after_adding(self): | 4094 | def test_reference_set_add_no_store_unlink_after_adding(self): |
3570 | 4096 | bar1 = Bar() | 4095 | bar1 = Bar() |
3571 | 4097 | bar1.id = 400 | 4096 | bar1.id = 400 |
3573 | 4098 | bar1.title = u"Title 400" | 4097 | bar1.title = "Title 400" |
3574 | 4099 | bar2 = Bar() | 4098 | bar2 = Bar() |
3575 | 4100 | bar2.id = 500 | 4099 | bar2.id = 500 |
3577 | 4101 | bar2.title = u"Title 500" | 4100 | bar2.title = "Title 500" |
3578 | 4102 | 4101 | ||
3579 | 4103 | foo = FooRefSet() | 4102 | foo = FooRefSet() |
3581 | 4104 | foo.title = u"Title 40" | 4103 | foo.title = "Title 40" |
3582 | 4105 | foo.bars.add(bar1) | 4104 | foo.bars.add(bar1) |
3583 | 4106 | foo.bars.add(bar2) | 4105 | foo.bars.add(bar2) |
3584 | 4107 | foo.bars.remove(bar1) | 4106 | foo.bars.remove(bar1) |
3585 | @@ -4152,15 +4151,15 @@ | |||
3586 | 4152 | def test_indirect_reference_set_with_added(self): | 4151 | def test_indirect_reference_set_with_added(self): |
3587 | 4153 | bar1 = Bar() | 4152 | bar1 = Bar() |
3588 | 4154 | bar1.id = 400 | 4153 | bar1.id = 400 |
3590 | 4155 | bar1.title = u"Title 400" | 4154 | bar1.title = "Title 400" |
3591 | 4156 | bar2 = Bar() | 4155 | bar2 = Bar() |
3592 | 4157 | bar2.id = 500 | 4156 | bar2.id = 500 |
3594 | 4158 | bar2.title = u"Title 500" | 4157 | bar2.title = "Title 500" |
3595 | 4159 | self.store.add(bar1) | 4158 | self.store.add(bar1) |
3596 | 4160 | self.store.add(bar2) | 4159 | self.store.add(bar2) |
3597 | 4161 | 4160 | ||
3598 | 4162 | foo = FooIndRefSet() | 4161 | foo = FooIndRefSet() |
3600 | 4163 | foo.title = u"Title 40" | 4162 | foo.title = "Title 40" |
3601 | 4164 | foo.bars.add(bar1) | 4163 | foo.bars.add(bar1) |
3602 | 4165 | foo.bars.add(bar2) | 4164 | foo.bars.add(bar2) |
3603 | 4166 | 4165 | ||
3604 | @@ -4181,7 +4180,7 @@ | |||
3605 | 4181 | foo = self.store.get(FooIndRefSet, 20) | 4180 | foo = self.store.get(FooIndRefSet, 20) |
3606 | 4182 | 4181 | ||
3607 | 4183 | items = [] | 4182 | items = [] |
3609 | 4184 | for bar in foo.bars.find(Bar.title == u"Title 300"): | 4183 | for bar in foo.bars.find(Bar.title == "Title 300"): |
3610 | 4185 | items.append((bar.id, bar.title)) | 4184 | items.append((bar.id, bar.title)) |
3611 | 4186 | items.sort() | 4185 | items.sort() |
3612 | 4187 | 4186 | ||
3613 | @@ -4454,10 +4453,10 @@ | |||
3614 | 4454 | foo.id = 40 | 4453 | foo.id = 40 |
3615 | 4455 | bar1 = Bar() | 4454 | bar1 = Bar() |
3616 | 4456 | bar1.id = 400 | 4455 | bar1.id = 400 |
3618 | 4457 | bar1.title = u"Title 400" | 4456 | bar1.title = "Title 400" |
3619 | 4458 | bar2 = Bar() | 4457 | bar2 = Bar() |
3620 | 4459 | bar2.id = 500 | 4458 | bar2.id = 500 |
3622 | 4460 | bar2.title = u"Title 500" | 4459 | bar2.title = "Title 500" |
3623 | 4461 | self.store.add(foo) | 4460 | self.store.add(foo) |
3624 | 4462 | self.store.add(bar1) | 4461 | self.store.add(bar1) |
3625 | 4463 | self.store.add(bar2) | 4462 | self.store.add(bar2) |
3626 | @@ -4478,13 +4477,13 @@ | |||
3627 | 4478 | def test_indirect_reference_set_with_added_no_store(self): | 4477 | def test_indirect_reference_set_with_added_no_store(self): |
3628 | 4479 | bar1 = Bar() | 4478 | bar1 = Bar() |
3629 | 4480 | bar1.id = 400 | 4479 | bar1.id = 400 |
3631 | 4481 | bar1.title = u"Title 400" | 4480 | bar1.title = "Title 400" |
3632 | 4482 | bar2 = Bar() | 4481 | bar2 = Bar() |
3633 | 4483 | bar2.id = 500 | 4482 | bar2.id = 500 |
3635 | 4484 | bar2.title = u"Title 500" | 4483 | bar2.title = "Title 500" |
3636 | 4485 | 4484 | ||
3637 | 4486 | foo = FooIndRefSet() | 4485 | foo = FooIndRefSet() |
3639 | 4487 | foo.title = u"Title 40" | 4486 | foo.title = "Title 40" |
3640 | 4488 | 4487 | ||
3641 | 4489 | foo.bars.add(bar1) | 4488 | foo.bars.add(bar1) |
3642 | 4490 | foo.bars.add(bar2) | 4489 | foo.bars.add(bar2) |
3643 | @@ -4629,7 +4628,7 @@ | |||
3644 | 4629 | foo5 = Foo() | 4628 | foo5 = Foo() |
3645 | 4630 | 4629 | ||
3646 | 4631 | for i, foo in enumerate([foo1, foo2, foo3, foo4, foo5]): | 4630 | for i, foo in enumerate([foo1, foo2, foo3, foo4, foo5]): |
3648 | 4632 | foo.title = u"Object %d" % (i+1) | 4631 | foo.title = "Object %d" % (i+1) |
3649 | 4633 | self.store.add(foo) | 4632 | self.store.add(foo) |
3650 | 4634 | 4633 | ||
3651 | 4635 | self.store.add_flush_order(foo2, foo4) | 4634 | self.store.add_flush_order(foo2, foo4) |
3652 | @@ -4660,7 +4659,7 @@ | |||
3653 | 4660 | 4659 | ||
3654 | 4661 | def test_variable_filter_on_update(self): | 4660 | def test_variable_filter_on_update(self): |
3655 | 4662 | foo = self.store.get(FooVariable, 20) | 4661 | foo = self.store.get(FooVariable, 20) |
3657 | 4663 | foo.title = u"Title 20" | 4662 | foo.title = "Title 20" |
3658 | 4664 | 4663 | ||
3659 | 4665 | self.store.flush() | 4664 | self.store.flush() |
3660 | 4666 | 4665 | ||
3661 | @@ -4682,7 +4681,7 @@ | |||
3662 | 4682 | def test_variable_filter_on_insert(self): | 4681 | def test_variable_filter_on_insert(self): |
3663 | 4683 | foo = FooVariable() | 4682 | foo = FooVariable() |
3664 | 4684 | foo.id = 40 | 4683 | foo.id = 40 |
3666 | 4685 | foo.title = u"Title 40" | 4684 | foo.title = "Title 40" |
3667 | 4686 | 4685 | ||
3668 | 4687 | self.store.add(foo) | 4686 | self.store.add(foo) |
3669 | 4688 | self.store.flush() | 4687 | self.store.flush() |
3670 | @@ -4705,7 +4704,7 @@ | |||
3671 | 4705 | 4704 | ||
3672 | 4706 | def test_variable_filter_on_set(self): | 4705 | def test_variable_filter_on_set(self): |
3673 | 4707 | foo = FooVariable() | 4706 | foo = FooVariable() |
3675 | 4708 | self.store.find(FooVariable, id=20).set(title=u"Title 20") | 4707 | self.store.find(FooVariable, id=20).set(title="Title 20") |
3676 | 4709 | 4708 | ||
3677 | 4710 | self.assertEqual(self.get_items(), [ | 4709 | self.assertEqual(self.get_items(), [ |
3678 | 4711 | (10, "Title 30"), | 4710 | (10, "Title 30"), |
3679 | @@ -4716,7 +4715,7 @@ | |||
3680 | 4716 | def test_variable_filter_on_set_expr(self): | 4715 | def test_variable_filter_on_set_expr(self): |
3681 | 4717 | foo = FooVariable() | 4716 | foo = FooVariable() |
3682 | 4718 | result = self.store.find(FooVariable, id=20) | 4717 | result = self.store.find(FooVariable, id=20) |
3684 | 4719 | result.set(FooVariable.title == u"Title 20") | 4718 | result.set(FooVariable.title == "Title 20") |
3685 | 4720 | 4719 | ||
3686 | 4721 | self.assertEqual(self.get_items(), [ | 4720 | self.assertEqual(self.get_items(), [ |
3687 | 4722 | (10, "Title 30"), | 4721 | (10, "Title 30"), |
3688 | @@ -4730,7 +4729,7 @@ | |||
3689 | 4730 | class MyResult(Result): | 4729 | class MyResult(Result): |
3690 | 4731 | def set_variable(self, variable, value): | 4730 | def set_variable(self, variable, value): |
3691 | 4732 | if variable.__class__ is UnicodeVariable: | 4731 | if variable.__class__ is UnicodeVariable: |
3693 | 4733 | variable.set(u"set_variable(%s)" % value) | 4732 | variable.set("set_variable(%s)" % value) |
3694 | 4734 | elif variable.__class__ is IntVariable: | 4733 | elif variable.__class__ is IntVariable: |
3695 | 4735 | variable.set(value+1) | 4734 | variable.set(value+1) |
3696 | 4736 | else: | 4735 | else: |
3697 | @@ -4747,7 +4746,7 @@ | |||
3698 | 4747 | 4746 | ||
3699 | 4748 | def test_default(self): | 4747 | def test_default(self): |
3700 | 4749 | class MyFoo(Foo): | 4748 | class MyFoo(Foo): |
3702 | 4750 | title = Unicode(default=u"Some default value") | 4749 | title = Unicode(default="Some default value") |
3703 | 4751 | 4750 | ||
3704 | 4752 | foo = MyFoo() | 4751 | foo = MyFoo() |
3705 | 4753 | self.store.add(foo) | 4752 | self.store.add(foo) |
3706 | @@ -4761,7 +4760,7 @@ | |||
3707 | 4761 | 4760 | ||
3708 | 4762 | def test_default_factory(self): | 4761 | def test_default_factory(self): |
3709 | 4763 | class MyFoo(Foo): | 4762 | class MyFoo(Foo): |
3711 | 4764 | title = Unicode(default_factory=lambda:u"Some default value") | 4763 | title = Unicode(default_factory=lambda:"Some default value") |
3712 | 4765 | 4764 | ||
3713 | 4766 | foo = MyFoo() | 4765 | foo = MyFoo() |
3714 | 4767 | self.store.add(foo) | 4766 | self.store.add(foo) |
3715 | @@ -4927,14 +4926,14 @@ | |||
3716 | 4927 | it is used to fill up any undefined variables. | 4926 | it is used to fill up any undefined variables. |
3717 | 4928 | """ | 4927 | """ |
3718 | 4929 | # We do a first find to get the object_infos into the cache. | 4928 | # We do a first find to get the object_infos into the cache. |
3720 | 4930 | foos = list(self.store.find(Foo, title=u"Title 20")) | 4929 | foos = list(self.store.find(Foo, title="Title 20")) |
3721 | 4931 | 4930 | ||
3722 | 4932 | # Commit so that all foos are invalidated and variables are | 4931 | # Commit so that all foos are invalidated and variables are |
3723 | 4933 | # set back to AutoReload. | 4932 | # set back to AutoReload. |
3724 | 4934 | self.store.commit() | 4933 | self.store.commit() |
3725 | 4935 | 4934 | ||
3726 | 4936 | # Another find which should reuse in-memory foos. | 4935 | # Another find which should reuse in-memory foos. |
3728 | 4937 | for foo in self.store.find(Foo, title=u"Title 20"): | 4936 | for foo in self.store.find(Foo, title="Title 20"): |
3729 | 4938 | # Make sure we have all variables defined, because | 4937 | # Make sure we have all variables defined, because |
3730 | 4939 | # values were already retrieved by the find's select. | 4938 | # values were already retrieved by the find's select. |
3731 | 4940 | obj_info = get_obj_info(foo) | 4939 | obj_info = get_obj_info(foo) |
3732 | @@ -4969,7 +4968,7 @@ | |||
3733 | 4969 | # set back to AutoReload. | 4968 | # set back to AutoReload. |
3734 | 4970 | self.store.commit() | 4969 | self.store.commit() |
3735 | 4971 | 4970 | ||
3737 | 4972 | foo = self.store.find(MyFoo, title=u"Title 20").one() | 4971 | foo = self.store.find(MyFoo, title="Title 20").one() |
3738 | 4973 | self.assertEqual(foo.id, 20) | 4972 | self.assertEqual(foo.id, 20) |
3739 | 4974 | self.assertEqual(len(loaded), 2) | 4973 | self.assertEqual(len(loaded), 2) |
3740 | 4975 | 4974 | ||
3741 | @@ -4982,7 +4981,7 @@ | |||
3742 | 4982 | """ | 4981 | """ |
3743 | 4983 | blob = self.store.get(Blob, 20) | 4982 | blob = self.store.get(Blob, 20) |
3744 | 4984 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." | 4983 | blob.bin = b"\x80\x02}q\x01U\x01aK\x01s." |
3746 | 4985 | class PickleBlob(object): | 4984 | class PickleBlob: |
3747 | 4986 | __storm_table__ = "bin" | 4985 | __storm_table__ = "bin" |
3748 | 4987 | id = Int(primary=True) | 4986 | id = Int(primary=True) |
3749 | 4988 | pickle = Pickle("bin") | 4987 | pickle = Pickle("bin") |
3750 | @@ -5024,7 +5023,7 @@ | |||
3751 | 5024 | 5023 | ||
3752 | 5025 | new_obj = DictFoo() | 5024 | new_obj = DictFoo() |
3753 | 5026 | new_obj.id = 40 | 5025 | new_obj.id = 40 |
3755 | 5027 | new_obj.title = u"My Title" | 5026 | new_obj.title = "My Title" |
3756 | 5028 | 5027 | ||
3757 | 5029 | self.store.add(new_obj) | 5028 | self.store.add(new_obj) |
3758 | 5030 | self.store.commit() | 5029 | self.store.commit() |
3759 | @@ -5122,7 +5121,7 @@ | |||
3760 | 5122 | self.assertTrue(lazy_value is AutoReload) | 5121 | self.assertTrue(lazy_value is AutoReload) |
3761 | 5123 | 5122 | ||
3762 | 5124 | # Which gets resolved once touched. | 5123 | # Which gets resolved once touched. |
3764 | 5125 | self.assertEqual(foo.title, u"New title") | 5124 | self.assertEqual(foo.title, "New title") |
3765 | 5126 | 5125 | ||
3766 | 5127 | def test_expr_values_flush_on_demand_with_added(self): | 5126 | def test_expr_values_flush_on_demand_with_added(self): |
3767 | 5128 | foo = Foo() | 5127 | foo = Foo() |
3768 | @@ -5353,7 +5352,7 @@ | |||
3769 | 5353 | foo = Foo() | 5352 | foo = Foo() |
3770 | 5354 | self.store.add(foo) | 5353 | self.store.add(foo) |
3771 | 5355 | foo.id = AutoReload | 5354 | foo.id = AutoReload |
3773 | 5356 | foo.title = u"New Title" | 5355 | foo.title = "New Title" |
3774 | 5357 | self.assertTrue(isinstance(foo.id, int)) | 5356 | self.assertTrue(isinstance(foo.id, int)) |
3775 | 5358 | self.assertEqual(foo.title, "New Title") | 5357 | self.assertEqual(foo.title, "New Title") |
3776 | 5359 | 5358 | ||
3777 | @@ -5401,7 +5400,7 @@ | |||
3778 | 5401 | self.store.flush() | 5400 | self.store.flush() |
3779 | 5402 | lazy_value = get_obj_info(foo).variables[Foo.title].get_lazy() | 5401 | lazy_value = get_obj_info(foo).variables[Foo.title].get_lazy() |
3780 | 5403 | self.assertEqual(lazy_value, AutoReload) | 5402 | self.assertEqual(lazy_value, AutoReload) |
3782 | 5404 | self.assertEqual(foo.title, u"Default Title") | 5403 | self.assertEqual(foo.title, "Default Title") |
3783 | 5405 | 5404 | ||
3784 | 5406 | def test_reference_break_on_local_diverged_doesnt_autoreload(self): | 5405 | def test_reference_break_on_local_diverged_doesnt_autoreload(self): |
3785 | 5407 | foo = self.store.get(Foo, 10) | 5406 | foo = self.store.get(Foo, 10) |
3786 | @@ -5422,7 +5421,7 @@ | |||
3787 | 5422 | committed, detecting if the referenced object has been removed behind | 5421 | committed, detecting if the referenced object has been removed behind |
3788 | 5423 | its back. | 5422 | its back. |
3789 | 5424 | """ | 5423 | """ |
3791 | 5425 | class BarOnRemote(object): | 5424 | class BarOnRemote: |
3792 | 5426 | __storm_table__ = "bar" | 5425 | __storm_table__ = "bar" |
3793 | 5427 | foo_id = Int(primary=True) | 5426 | foo_id = Int(primary=True) |
3794 | 5428 | foo = Reference(foo_id, Foo.id, on_remote=True) | 5427 | foo = Reference(foo_id, Foo.id, on_remote=True) |
3795 | @@ -5476,7 +5475,7 @@ | |||
3796 | 5476 | self.store.add(foo) | 5475 | self.store.add(foo) |
3797 | 5477 | self.store.invalidate(foo) | 5476 | self.store.invalidate(foo) |
3798 | 5478 | foo.id = 40 | 5477 | foo.id = 40 |
3800 | 5479 | foo.title = u"Title 40" | 5478 | foo.title = "Title 40" |
3801 | 5480 | self.store.flush() | 5479 | self.store.flush() |
3802 | 5481 | 5480 | ||
3803 | 5482 | # Object must have a valid cache at this point, since it was | 5481 | # Object must have a valid cache at this point, since it was |
3804 | @@ -5488,7 +5487,7 @@ | |||
3805 | 5488 | foo = self.store.get(Foo, 20) | 5487 | foo = self.store.get(Foo, 20) |
3806 | 5489 | self.store.execute("DELETE FROM foo WHERE id=20") | 5488 | self.store.execute("DELETE FROM foo WHERE id=20") |
3807 | 5490 | self.store.invalidate(foo) | 5489 | self.store.invalidate(foo) |
3809 | 5491 | self.assertRaises(LostObjectError, setattr, foo, "title", u"Title 40") | 5490 | self.assertRaises(LostObjectError, setattr, foo, "title", "Title 40") |
3810 | 5492 | 5491 | ||
3811 | 5493 | def test_invalidated_objects_reloaded_by_get(self): | 5492 | def test_invalidated_objects_reloaded_by_get(self): |
3812 | 5494 | foo = self.store.get(Foo, 20) | 5493 | foo = self.store.get(Foo, 20) |
3813 | @@ -5496,7 +5495,7 @@ | |||
3814 | 5496 | foo = self.store.get(Foo, 20) | 5495 | foo = self.store.get(Foo, 20) |
3815 | 5497 | title_variable = get_obj_info(foo).variables[Foo.title] | 5496 | title_variable = get_obj_info(foo).variables[Foo.title] |
3816 | 5498 | self.assertEqual(title_variable.get_lazy(), None) | 5497 | self.assertEqual(title_variable.get_lazy(), None) |
3818 | 5499 | self.assertEqual(title_variable.get(), u"Title 20") | 5498 | self.assertEqual(title_variable.get(), "Title 20") |
3819 | 5500 | self.assertEqual(foo.title, "Title 20") | 5499 | self.assertEqual(foo.title, "Title 20") |
3820 | 5501 | 5500 | ||
3821 | 5502 | def test_invalidated_hook(self): | 5501 | def test_invalidated_hook(self): |
3822 | @@ -5548,7 +5547,7 @@ | |||
3823 | 5548 | """ | 5547 | """ |
3824 | 5549 | foo1 = self.store.get(Foo, 10) | 5548 | foo1 = self.store.get(Foo, 10) |
3825 | 5550 | foo1_title = foo1.title | 5549 | foo1_title = foo1.title |
3827 | 5551 | foo1.title = u"radix wuz here" | 5550 | foo1.title = "radix wuz here" |
3828 | 5552 | self.store.reset() | 5551 | self.store.reset() |
3829 | 5553 | self.store.flush() | 5552 | self.store.flush() |
3830 | 5554 | new_foo1 = self.store.get(Foo, 10) | 5553 | new_foo1 = self.store.get(Foo, 10) |
3831 | @@ -5587,14 +5586,14 @@ | |||
3832 | 5587 | def test_result_find_introduce_join(self): | 5586 | def test_result_find_introduce_join(self): |
3833 | 5588 | result1 = self.store.find(Foo, Foo.id <= 20) | 5587 | result1 = self.store.find(Foo, Foo.id <= 20) |
3834 | 5589 | result2 = result1.find(Foo.id == Bar.foo_id, | 5588 | result2 = result1.find(Foo.id == Bar.foo_id, |
3836 | 5590 | Bar.title == u"Title 300") | 5589 | Bar.title == "Title 300") |
3837 | 5591 | foo = result2.one() | 5590 | foo = result2.one() |
3838 | 5592 | self.assertTrue(foo) | 5591 | self.assertTrue(foo) |
3839 | 5593 | self.assertEqual(foo.id, 10) | 5592 | self.assertEqual(foo.id, 10) |
3840 | 5594 | 5593 | ||
3841 | 5595 | def test_result_find_tuple(self): | 5594 | def test_result_find_tuple(self): |
3842 | 5596 | result1 = self.store.find((Foo, Bar), Foo.id == Bar.foo_id) | 5595 | result1 = self.store.find((Foo, Bar), Foo.id == Bar.foo_id) |
3844 | 5597 | result2 = result1.find(Bar.title == u"Title 100") | 5596 | result2 = result1.find(Bar.title == "Title 100") |
3845 | 5598 | foo_bar = result2.one() | 5597 | foo_bar = result2.one() |
3846 | 5599 | self.assertTrue(foo_bar) | 5598 | self.assertTrue(foo_bar) |
3847 | 5600 | foo, bar = foo_bar | 5599 | foo, bar = foo_bar |
3848 | @@ -5694,7 +5693,7 @@ | |||
3849 | 5694 | result2 = self.store.find(Foo, id=10) | 5693 | result2 = self.store.find(Foo, id=10) |
3850 | 5695 | result3 = result1.union(result2) | 5694 | result3 = result1.union(result2) |
3851 | 5696 | 5695 | ||
3853 | 5697 | self.assertRaises(FeatureError, result3.set, title=u"Title 40") | 5696 | self.assertRaises(FeatureError, result3.set, title="Title 40") |
3854 | 5698 | self.assertRaises(FeatureError, result3.remove) | 5697 | self.assertRaises(FeatureError, result3.remove) |
3855 | 5699 | 5698 | ||
3856 | 5700 | def test_result_union_count(self): | 5699 | def test_result_union_count(self): |
3857 | @@ -5848,7 +5847,7 @@ | |||
3858 | 5848 | self.assertEqual(bar.foo_title, "Title 20") | 5847 | self.assertEqual(bar.foo_title, "Title 20") |
3859 | 5849 | 5848 | ||
3860 | 5850 | def test_proxy_equals(self): | 5849 | def test_proxy_equals(self): |
3862 | 5851 | bar = self.store.find(BarProxy, BarProxy.foo_title == u"Title 20").one() | 5850 | bar = self.store.find(BarProxy, BarProxy.foo_title == "Title 20").one() |
3863 | 5852 | self.assertTrue(bar) | 5851 | self.assertTrue(bar) |
3864 | 5853 | self.assertEqual(bar.id, 200) | 5852 | self.assertEqual(bar.id, 200) |
3865 | 5854 | 5853 | ||
3866 | @@ -5859,7 +5858,7 @@ | |||
3867 | 5859 | 5858 | ||
3868 | 5860 | def test_proxy_set(self): | 5859 | def test_proxy_set(self): |
3869 | 5861 | bar = self.store.get(BarProxy, 200) | 5860 | bar = self.store.get(BarProxy, 200) |
3871 | 5862 | bar.foo_title = u"New Title" | 5861 | bar.foo_title = "New Title" |
3872 | 5863 | foo = self.store.get(Foo, 20) | 5862 | foo = self.store.get(Foo, 20) |
3873 | 5864 | self.assertEqual(foo.title, "New Title") | 5863 | self.assertEqual(foo.title, "New Title") |
3874 | 5865 | 5864 | ||
3875 | @@ -5888,7 +5887,7 @@ | |||
3876 | 5888 | 5887 | ||
3877 | 5889 | def test_proxy_with_string_variable_factory_attribute(self): | 5888 | def test_proxy_with_string_variable_factory_attribute(self): |
3878 | 5890 | MyBarProxy, MyFoo = self.get_bar_proxy_with_string() | 5889 | MyBarProxy, MyFoo = self.get_bar_proxy_with_string() |
3880 | 5891 | variable = MyBarProxy.foo_title.variable_factory(value=u"Hello") | 5890 | variable = MyBarProxy.foo_title.variable_factory(value="Hello") |
3881 | 5892 | self.assertTrue(isinstance(variable, UnicodeVariable)) | 5891 | self.assertTrue(isinstance(variable, UnicodeVariable)) |
3882 | 5893 | 5892 | ||
3883 | 5894 | def test_proxy_with_extra_table(self): | 5893 | def test_proxy_with_extra_table(self): |
3884 | @@ -5897,13 +5896,13 @@ | |||
3885 | 5897 | more tables in the query. | 5896 | more tables in the query. |
3886 | 5898 | """ | 5897 | """ |
3887 | 5899 | result = self.store.find((BarProxy, Link), | 5898 | result = self.store.find((BarProxy, Link), |
3889 | 5900 | BarProxy.foo_title == u"Title 20", | 5899 | BarProxy.foo_title == "Title 20", |
3890 | 5901 | BarProxy.foo_id == Link.foo_id) | 5900 | BarProxy.foo_id == Link.foo_id) |
3891 | 5902 | results = list(result) | 5901 | results = list(result) |
3892 | 5903 | self.assertEqual(len(results), 2) | 5902 | self.assertEqual(len(results), 2) |
3893 | 5904 | for bar, link in results: | 5903 | for bar, link in results: |
3894 | 5905 | self.assertEqual(bar.id, 200) | 5904 | self.assertEqual(bar.id, 200) |
3896 | 5906 | self.assertEqual(bar.foo_title, u"Title 20") | 5905 | self.assertEqual(bar.foo_title, "Title 20") |
3897 | 5907 | self.assertEqual(bar.foo_id, 20) | 5906 | self.assertEqual(bar.foo_id, 20) |
3898 | 5908 | self.assertEqual(link.foo_id, 20) | 5907 | self.assertEqual(link.foo_id, 20) |
3899 | 5909 | 5908 | ||
3900 | @@ -5942,7 +5941,7 @@ | |||
3901 | 5942 | check.append([column.name for column in primary_columns]) | 5941 | check.append([column.name for column in primary_columns]) |
3902 | 5943 | primary_variables[0].set(SQL("40")) | 5942 | primary_variables[0].set(SQL("40")) |
3903 | 5944 | 5943 | ||
3905 | 5945 | class DatabaseWrapper(object): | 5944 | class DatabaseWrapper: |
3906 | 5946 | """Wrapper to inject our custom preset_primary_key hook.""" | 5945 | """Wrapper to inject our custom preset_primary_key hook.""" |
3907 | 5947 | 5946 | ||
3908 | 5948 | def __init__(self, database): | 5947 | def __init__(self, database): |
3909 | @@ -6027,7 +6026,7 @@ | |||
3910 | 6027 | pass | 6026 | pass |
3911 | 6028 | foo = self.store.get(Foo, 20) | 6027 | foo = self.store.get(Foo, 20) |
3912 | 6029 | myfoo = self.store.get(MyFoo, 20) | 6028 | myfoo = self.store.get(MyFoo, 20) |
3914 | 6030 | for title in [u'Cừơng', u'Đức', u'Hạnh']: | 6029 | for title in ['Cừơng', 'Đức', 'Hạnh']: |
3915 | 6031 | foo.title = title | 6030 | foo.title = title |
3916 | 6032 | self.store.commit() | 6031 | self.store.commit() |
3917 | 6033 | try: | 6032 | try: |
3918 | @@ -6055,7 +6054,7 @@ | |||
3919 | 6055 | 6054 | ||
3920 | 6056 | MyFoo.sequence = 0 | 6055 | MyFoo.sequence = 0 |
3921 | 6057 | for foo in foos: | 6056 | for foo in foos: |
3923 | 6058 | foo.title = u"Changed Title" | 6057 | foo.title = "Changed Title" |
3924 | 6059 | self.store.flush() | 6058 | self.store.flush() |
3925 | 6060 | 6059 | ||
3926 | 6061 | for i, foo in enumerate(foos): | 6060 | for i, foo in enumerate(foos): |
3927 | @@ -6089,16 +6088,16 @@ | |||
3928 | 6089 | """ | 6088 | """ |
3929 | 6090 | store = self.create_store() | 6089 | store = self.create_store() |
3930 | 6091 | foo2 = store.get(Foo, 10) | 6090 | foo2 = store.get(Foo, 10) |
3932 | 6092 | self.assertEqual(foo2.title, u"Title 30") | 6091 | self.assertEqual(foo2.title, "Title 30") |
3933 | 6093 | store.commit() | 6092 | store.commit() |
3934 | 6094 | 6093 | ||
3935 | 6095 | foo1 = self.store.get(Foo, 10) | 6094 | foo1 = self.store.get(Foo, 10) |
3937 | 6096 | foo1.title = u"Title 40" | 6095 | foo1.title = "Title 40" |
3938 | 6097 | self.store.commit() | 6096 | self.store.commit() |
3939 | 6098 | 6097 | ||
3941 | 6099 | foo2.title = u"Title 30" | 6098 | foo2.title = "Title 30" |
3942 | 6100 | store.commit() | 6099 | store.commit() |
3944 | 6101 | self.assertEqual(foo2.title, u"Title 30") | 6100 | self.assertEqual(foo2.title, "Title 30") |
3945 | 6102 | 6101 | ||
3946 | 6103 | def test_execute_sends_event(self): | 6102 | def test_execute_sends_event(self): |
3947 | 6104 | """Statement execution emits the register-transaction event.""" | 6103 | """Statement execution emits the register-transaction event.""" |
3948 | @@ -6131,7 +6130,7 @@ | |||
3949 | 6131 | calls.append(owner) | 6130 | calls.append(owner) |
3950 | 6132 | self.store._event.hook("register-transaction", register_transaction) | 6131 | self.store._event.hook("register-transaction", register_transaction) |
3951 | 6133 | foo = Foo() | 6132 | foo = Foo() |
3953 | 6134 | foo.title = u"Foo" | 6133 | foo.title = "Foo" |
3954 | 6135 | self.store.add(foo) | 6134 | self.store.add(foo) |
3955 | 6136 | self.assertEqual(len(calls), 1) | 6135 | self.assertEqual(len(calls), 1) |
3956 | 6137 | self.assertEqual(calls[0], self.store) | 6136 | self.assertEqual(calls[0], self.store) |
3957 | @@ -6160,7 +6159,7 @@ | |||
3958 | 6160 | self.store.rollback() | 6159 | self.store.rollback() |
3959 | 6161 | del calls[:] | 6160 | del calls[:] |
3960 | 6162 | 6161 | ||
3962 | 6163 | foo.title = u"New title" | 6162 | foo.title = "New title" |
3963 | 6164 | self.assertEqual(len(calls), 1) | 6163 | self.assertEqual(len(calls), 1) |
3964 | 6165 | self.assertEqual(calls[0], self.store) | 6164 | self.assertEqual(calls[0], self.store) |
3965 | 6166 | 6165 | ||
3966 | @@ -6170,7 +6169,7 @@ | |||
3967 | 6170 | self.assertEqual(result_to_remove.remove(), 3) | 6169 | self.assertEqual(result_to_remove.remove(), 3) |
3968 | 6171 | 6170 | ||
3969 | 6172 | 6171 | ||
3971 | 6173 | class EmptyResultSetTest(object): | 6172 | class EmptyResultSetTest: |
3972 | 6174 | 6173 | ||
3973 | 6175 | def setUp(self): | 6174 | def setUp(self): |
3974 | 6176 | self.create_database() | 6175 | self.create_database() |
3975 | @@ -6346,8 +6345,8 @@ | |||
3976 | 6346 | self.assertEqual(self.empty.cached(), []) | 6345 | self.assertEqual(self.empty.cached(), []) |
3977 | 6347 | 6346 | ||
3978 | 6348 | def test_find(self): | 6347 | def test_find(self): |
3981 | 6349 | self.assertEqual(list(self.result.find(Foo.title == u"foo")), []) | 6348 | self.assertEqual(list(self.result.find(Foo.title == "foo")), []) |
3982 | 6350 | self.assertEqual(list(self.empty.find(Foo.title == u"foo")), []) | 6349 | self.assertEqual(list(self.empty.find(Foo.title == "foo")), []) |
3983 | 6351 | 6350 | ||
3984 | 6352 | def test_union(self): | 6351 | def test_union(self): |
3985 | 6353 | self.assertEqual(self.empty.union(self.empty), self.empty) | 6352 | self.assertEqual(self.empty.union(self.empty), self.empty) |
3986 | 6354 | 6353 | ||
3987 | === modified file 'storm/tests/store/block.py' | |||
3988 | --- storm/tests/store/block.py 2020-03-18 16:20:14 +0000 | |||
3989 | +++ storm/tests/store/block.py 2024-03-13 16:26:38 +0000 | |||
3990 | @@ -30,7 +30,7 @@ | |||
3991 | 30 | helpers = [MakePath] | 30 | helpers = [MakePath] |
3992 | 31 | 31 | ||
3993 | 32 | def setUp(self): | 32 | def setUp(self): |
3995 | 33 | super(BlockAccessTest, self).setUp() | 33 | super().setUp() |
3996 | 34 | database = SQLite(URI("sqlite:")) | 34 | database = SQLite(URI("sqlite:")) |
3997 | 35 | self.store = Store(database) | 35 | self.store = Store(database) |
3998 | 36 | 36 | ||
3999 | 37 | 37 | ||
4000 | === modified file 'storm/tests/store/postgres.py' | |||
4001 | --- storm/tests/store/postgres.py 2024-03-04 10:59:55 +0000 | |||
4002 | +++ storm/tests/store/postgres.py 2024-03-13 16:26:38 +0000 | |||
4003 | @@ -28,17 +28,17 @@ | |||
4004 | 28 | from storm.tests.helper import TestHelper | 28 | from storm.tests.helper import TestHelper |
4005 | 29 | 29 | ||
4006 | 30 | 30 | ||
4008 | 31 | class Lst1(object): | 31 | class Lst1: |
4009 | 32 | __storm_table__ = "lst1" | 32 | __storm_table__ = "lst1" |
4010 | 33 | id = Int(primary=True) | 33 | id = Int(primary=True) |
4011 | 34 | ints = List(type=Int()) | 34 | ints = List(type=Int()) |
4012 | 35 | 35 | ||
4014 | 36 | class LstEnum(object): | 36 | class LstEnum: |
4015 | 37 | __storm_table__ = "lst1" | 37 | __storm_table__ = "lst1" |
4016 | 38 | id = Int(primary=True) | 38 | id = Int(primary=True) |
4017 | 39 | ints = List(type=Enum(map={"one": 1, "two": 2, "three": 3})) | 39 | ints = List(type=Enum(map={"one": 1, "two": 2, "three": 3})) |
4018 | 40 | 40 | ||
4020 | 41 | class Lst2(object): | 41 | class Lst2: |
4021 | 42 | __storm_table__ = "lst2" | 42 | __storm_table__ = "lst2" |
4022 | 43 | id = Int(primary=True) | 43 | id = Int(primary=True) |
4023 | 44 | ints = List(type=List(type=Int())) | 44 | ints = List(type=List(type=Int())) |
4024 | @@ -170,7 +170,7 @@ | |||
4025 | 170 | 170 | ||
4026 | 171 | def test_add_find_with_schema(self): | 171 | def test_add_find_with_schema(self): |
4027 | 172 | foo = FooWithSchema() | 172 | foo = FooWithSchema() |
4029 | 173 | foo.title = u"Title" | 173 | foo.title = "Title" |
4030 | 174 | self.store.add(foo) | 174 | self.store.add(foo) |
4031 | 175 | self.store.flush() | 175 | self.store.flush() |
4032 | 176 | # We use find() here to actually exercise the backend code. | 176 | # We use find() here to actually exercise the backend code. |
4033 | 177 | 177 | ||
4034 | === modified file 'storm/tests/tracer.py' | |||
4035 | --- storm/tests/tracer.py 2024-03-04 10:59:55 +0000 | |||
4036 | +++ storm/tests/tracer.py 2024-03-13 16:26:38 +0000 | |||
4037 | @@ -32,7 +32,7 @@ | |||
4038 | 32 | class TracerTest(TestHelper): | 32 | class TracerTest(TestHelper): |
4039 | 33 | 33 | ||
4040 | 34 | def tearDown(self): | 34 | def tearDown(self): |
4042 | 35 | super(TracerTest, self).tearDown() | 35 | super().tearDown() |
4043 | 36 | del _tracers[:] | 36 | del _tracers[:] |
4044 | 37 | 37 | ||
4045 | 38 | def test_install_tracer(self): | 38 | def test_install_tracer(self): |
4046 | @@ -63,7 +63,7 @@ | |||
4047 | 63 | self.assertEqual(get_tracers(), []) | 63 | self.assertEqual(get_tracers(), []) |
4048 | 64 | 64 | ||
4049 | 65 | def test_remove_tracer_type(self): | 65 | def test_remove_tracer_type(self): |
4051 | 66 | class C(object): | 66 | class C: |
4052 | 67 | pass | 67 | pass |
4053 | 68 | 68 | ||
4054 | 69 | class D(C): | 69 | class D(C): |
4055 | @@ -100,7 +100,7 @@ | |||
4056 | 100 | def test_trace(self): | 100 | def test_trace(self): |
4057 | 101 | stash = [] | 101 | stash = [] |
4058 | 102 | 102 | ||
4060 | 103 | class Tracer(object): | 103 | class Tracer: |
4061 | 104 | def m1(_, *args, **kwargs): | 104 | def m1(_, *args, **kwargs): |
4062 | 105 | stash.extend(["m1", args, kwargs]) | 105 | stash.extend(["m1", args, kwargs]) |
4063 | 106 | 106 | ||
4064 | @@ -126,7 +126,7 @@ | |||
4065 | 126 | class DebugTracerTest(TestHelper): | 126 | class DebugTracerTest(TestHelper): |
4066 | 127 | 127 | ||
4067 | 128 | def setUp(self): | 128 | def setUp(self): |
4069 | 129 | super(DebugTracerTest, self).setUp() | 129 | super().setUp() |
4070 | 130 | self.stream = self.mocker.mock(type(sys.stderr)) | 130 | self.stream = self.mocker.mock(type(sys.stderr)) |
4071 | 131 | self.tracer = DebugTracer(self.stream) | 131 | self.tracer = DebugTracer(self.stream) |
4072 | 132 | 132 | ||
4073 | @@ -139,7 +139,7 @@ | |||
4074 | 139 | 139 | ||
4075 | 140 | def tearDown(self): | 140 | def tearDown(self): |
4076 | 141 | del _tracers[:] | 141 | del _tracers[:] |
4078 | 142 | super(DebugTracerTest, self).tearDown() | 142 | super().tearDown() |
4079 | 143 | 143 | ||
4080 | 144 | def test_wb_debug_tracer_uses_stderr_by_default(self): | 144 | def test_wb_debug_tracer_uses_stderr_by_default(self): |
4081 | 145 | self.mocker.replay() | 145 | self.mocker.replay() |
4082 | @@ -233,7 +233,7 @@ | |||
4083 | 233 | tracer_class = TimeoutTracer | 233 | tracer_class = TimeoutTracer |
4084 | 234 | 234 | ||
4085 | 235 | def setUp(self): | 235 | def setUp(self): |
4087 | 236 | super(TimeoutTracerTestBase, self).setUp() | 236 | super().setUp() |
4088 | 237 | self.tracer = self.tracer_class() | 237 | self.tracer = self.tracer_class() |
4089 | 238 | self.raw_cursor = self.mocker.mock() | 238 | self.raw_cursor = self.mocker.mock() |
4090 | 239 | self.statement = self.mocker.mock() | 239 | self.statement = self.mocker.mock() |
4091 | @@ -241,13 +241,13 @@ | |||
4092 | 241 | 241 | ||
4093 | 242 | # Some data is kept in the connection, so we use a proxy to | 242 | # Some data is kept in the connection, so we use a proxy to |
4094 | 243 | # allow things we don't care about here to happen. | 243 | # allow things we don't care about here to happen. |
4096 | 244 | class Connection(object): | 244 | class Connection: |
4097 | 245 | pass | 245 | pass |
4098 | 246 | 246 | ||
4099 | 247 | self.connection = self.mocker.proxy(Connection()) | 247 | self.connection = self.mocker.proxy(Connection()) |
4100 | 248 | 248 | ||
4101 | 249 | def tearDown(self): | 249 | def tearDown(self): |
4103 | 250 | super(TimeoutTracerTestBase, self).tearDown() | 250 | super().tearDown() |
4104 | 251 | del _tracers[:] | 251 | del _tracers[:] |
4105 | 252 | 252 | ||
4106 | 253 | def execute(self): | 253 | def execute(self): |
4107 | @@ -384,14 +384,14 @@ | |||
4108 | 384 | class TimeoutTracerWithDBTest(TestHelper): | 384 | class TimeoutTracerWithDBTest(TestHelper): |
4109 | 385 | 385 | ||
4110 | 386 | def setUp(self): | 386 | def setUp(self): |
4112 | 387 | super(TimeoutTracerWithDBTest, self).setUp() | 387 | super().setUp() |
4113 | 388 | self.tracer = StuckInTimeTimeoutTracer(10) | 388 | self.tracer = StuckInTimeTimeoutTracer(10) |
4114 | 389 | install_tracer(self.tracer) | 389 | install_tracer(self.tracer) |
4115 | 390 | database = create_database(os.environ["STORM_POSTGRES_URI"]) | 390 | database = create_database(os.environ["STORM_POSTGRES_URI"]) |
4116 | 391 | self.connection = database.connect() | 391 | self.connection = database.connect() |
4117 | 392 | 392 | ||
4118 | 393 | def tearDown(self): | 393 | def tearDown(self): |
4120 | 394 | super(TimeoutTracerWithDBTest, self).tearDown() | 394 | super().tearDown() |
4121 | 395 | remove_tracer(self.tracer) | 395 | remove_tracer(self.tracer) |
4122 | 396 | self.connection.close() | 396 | self.connection.close() |
4123 | 397 | 397 | ||
4124 | @@ -430,7 +430,7 @@ | |||
4125 | 430 | class StuckInTimeTimeoutTracer(TimeoutTracer): | 430 | class StuckInTimeTimeoutTracer(TimeoutTracer): |
4126 | 431 | 431 | ||
4127 | 432 | def __init__(self, fixed_remaining_time): | 432 | def __init__(self, fixed_remaining_time): |
4129 | 433 | super(StuckInTimeTimeoutTracer, self).__init__() | 433 | super().__init__() |
4130 | 434 | self.set_statement_timeout_calls = [] | 434 | self.set_statement_timeout_calls = [] |
4131 | 435 | self.fixed_remaining_time = fixed_remaining_time | 435 | self.fixed_remaining_time = fixed_remaining_time |
4132 | 436 | 436 | ||
4133 | @@ -467,7 +467,7 @@ | |||
4134 | 467 | tracer = self.LoggingBaseStatementTracer() | 467 | tracer = self.LoggingBaseStatementTracer() |
4135 | 468 | conn = StubConnection() | 468 | conn = StubConnection() |
4136 | 469 | conn.param_mark = '%s' | 469 | conn.param_mark = '%s' |
4138 | 470 | var1 = MockVariable(u'VAR1') | 470 | var1 = MockVariable('VAR1') |
4139 | 471 | tracer.connection_raw_execute( | 471 | tracer.connection_raw_execute( |
4140 | 472 | conn, 'cursor', 'SELECT * FROM person where name = %s', [var1]) | 472 | conn, 'cursor', 'SELECT * FROM person where name = %s', [var1]) |
4141 | 473 | self.assertEqual( | 473 | self.assertEqual( |
4142 | @@ -478,7 +478,7 @@ | |||
4143 | 478 | """String parameters are formatted as a single quoted string.""" | 478 | """String parameters are formatted as a single quoted string.""" |
4144 | 479 | tracer = self.LoggingBaseStatementTracer() | 479 | tracer = self.LoggingBaseStatementTracer() |
4145 | 480 | conn = StubConnection() | 480 | conn = StubConnection() |
4147 | 481 | var1 = MockVariable(u'VAR1') | 481 | var1 = MockVariable('VAR1') |
4148 | 482 | tracer.connection_raw_execute( | 482 | tracer.connection_raw_execute( |
4149 | 483 | conn, 'cursor', 'SELECT * FROM person where name = ?', [var1]) | 483 | conn, 'cursor', 'SELECT * FROM person where name = ?', [var1]) |
4150 | 484 | self.assertEqual( | 484 | self.assertEqual( |
4151 | @@ -513,7 +513,7 @@ | |||
4152 | 513 | """% operators in LIKE statements are preserved.""" | 513 | """% operators in LIKE statements are preserved.""" |
4153 | 514 | tracer = self.LoggingBaseStatementTracer() | 514 | tracer = self.LoggingBaseStatementTracer() |
4154 | 515 | conn = StubConnection() | 515 | conn = StubConnection() |
4156 | 516 | var1 = MockVariable(u'substring') | 516 | var1 = MockVariable('substring') |
4157 | 517 | tracer.connection_raw_execute( | 517 | tracer.connection_raw_execute( |
4158 | 518 | conn, 'cursor', | 518 | conn, 'cursor', |
4159 | 519 | "SELECT * FROM person WHERE name LIKE '%%' || ? || '-suffix%%'", | 519 | "SELECT * FROM person WHERE name LIKE '%%' || ? || '-suffix%%'", |
4160 | @@ -526,14 +526,14 @@ | |||
4161 | 526 | def test_unformattable_statements_are_handled(self): | 526 | def test_unformattable_statements_are_handled(self): |
4162 | 527 | tracer = self.LoggingBaseStatementTracer() | 527 | tracer = self.LoggingBaseStatementTracer() |
4163 | 528 | conn = StubConnection() | 528 | conn = StubConnection() |
4165 | 529 | var1 = MockVariable(u'substring') | 529 | var1 = MockVariable('substring') |
4166 | 530 | tracer.connection_raw_execute( | 530 | tracer.connection_raw_execute( |
4167 | 531 | conn, 'cursor', "%s %s", | 531 | conn, 'cursor', "%s %s", |
4168 | 532 | [var1]) | 532 | [var1]) |
4169 | 533 | self.assertEqual( | 533 | self.assertEqual( |
4170 | 534 | [(conn, 'cursor', | 534 | [(conn, 'cursor', |
4171 | 535 | "Unformattable query: '%%s %%s' with params [%r]." % | 535 | "Unformattable query: '%%s %%s' with params [%r]." % |
4173 | 536 | u'substring')], | 536 | 'substring')], |
4174 | 537 | tracer.calls) | 537 | tracer.calls) |
4175 | 538 | 538 | ||
4176 | 539 | 539 | ||
4177 | @@ -605,7 +605,7 @@ | |||
4178 | 605 | return has_fixtures | 605 | return has_fixtures |
4179 | 606 | 606 | ||
4180 | 607 | def tearDown(self): | 607 | def tearDown(self): |
4182 | 608 | super(CaptureTracerTest, self).tearDown() | 608 | super().tearDown() |
4183 | 609 | del _tracers[:] | 609 | del _tracers[:] |
4184 | 610 | 610 | ||
4185 | 611 | def test_capture(self): | 611 | def test_capture(self): |
4186 | @@ -617,7 +617,7 @@ | |||
4187 | 617 | self.assertEqual([tracer], get_tracers()) | 617 | self.assertEqual([tracer], get_tracers()) |
4188 | 618 | conn = StubConnection() | 618 | conn = StubConnection() |
4189 | 619 | conn.param_mark = '%s' | 619 | conn.param_mark = '%s' |
4191 | 620 | var = MockVariable(u"var") | 620 | var = MockVariable("var") |
4192 | 621 | tracer.connection_raw_execute(conn, "cursor", "select %s", [var]) | 621 | tracer.connection_raw_execute(conn, "cursor", "select %s", [var]) |
4193 | 622 | self.assertEqual(["select 'var'"], tracer.queries) | 622 | self.assertEqual(["select 'var'"], tracer.queries) |
4194 | 623 | 623 | ||
4195 | 624 | 624 | ||
4196 | === modified file 'storm/tests/variables.py' | |||
4197 | --- storm/tests/variables.py 2024-03-04 10:59:55 +0000 | |||
4198 | +++ storm/tests/variables.py 2024-03-13 16:26:38 +0000 | |||
4199 | @@ -35,7 +35,7 @@ | |||
4200 | 35 | from storm.tests.helper import TestHelper | 35 | from storm.tests.helper import TestHelper |
4201 | 36 | 36 | ||
4202 | 37 | 37 | ||
4204 | 38 | class Marker(object): | 38 | class Marker: |
4205 | 39 | pass | 39 | pass |
4206 | 40 | 40 | ||
4207 | 41 | marker = Marker() | 41 | marker = Marker() |
4208 | @@ -461,15 +461,15 @@ | |||
4209 | 461 | self.assertEqual(variable.get(), b"str") | 461 | self.assertEqual(variable.get(), b"str") |
4210 | 462 | variable.set(memoryview(b"buffer")) | 462 | variable.set(memoryview(b"buffer")) |
4211 | 463 | self.assertEqual(variable.get(), b"buffer") | 463 | self.assertEqual(variable.get(), b"buffer") |
4213 | 464 | self.assertRaises(TypeError, variable.set, u"unicode") | 464 | self.assertRaises(TypeError, variable.set, "unicode") |
4214 | 465 | 465 | ||
4215 | 466 | 466 | ||
4216 | 467 | class UnicodeVariableTest(TestHelper): | 467 | class UnicodeVariableTest(TestHelper): |
4217 | 468 | 468 | ||
4218 | 469 | def test_set_get(self): | 469 | def test_set_get(self): |
4219 | 470 | variable = UnicodeVariable() | 470 | variable = UnicodeVariable() |
4222 | 471 | variable.set(u"unicode") | 471 | variable.set("unicode") |
4223 | 472 | self.assertEqual(variable.get(), u"unicode") | 472 | self.assertEqual(variable.get(), "unicode") |
4224 | 473 | self.assertRaises(TypeError, variable.set, b"str") | 473 | self.assertRaises(TypeError, variable.set, b"str") |
4225 | 474 | 474 | ||
4226 | 475 | 475 | ||
4227 | @@ -814,7 +814,7 @@ | |||
4228 | 814 | self.assertRaises(TypeError, variable.set, | 814 | self.assertRaises(TypeError, variable.set, |
4229 | 815 | "0609f76b-878f-4546-baf5-c1b135e8de72") | 815 | "0609f76b-878f-4546-baf5-c1b135e8de72") |
4230 | 816 | self.assertRaises(TypeError, variable.set, | 816 | self.assertRaises(TypeError, variable.set, |
4232 | 817 | u"0609f76b-878f-4546-baf5-c1b135e8de72") | 817 | "0609f76b-878f-4546-baf5-c1b135e8de72") |
4233 | 818 | 818 | ||
4234 | 819 | def test_get_set_from_database(self): | 819 | def test_get_set_from_database(self): |
4235 | 820 | value = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}") | 820 | value = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}") |
4236 | @@ -826,7 +826,7 @@ | |||
4237 | 826 | self.assertEqual(variable.get(), value) | 826 | self.assertEqual(variable.get(), value) |
4238 | 827 | variable.set("0609f76b-878f-4546-baf5-c1b135e8de72", from_db=True) | 827 | variable.set("0609f76b-878f-4546-baf5-c1b135e8de72", from_db=True) |
4239 | 828 | self.assertEqual(variable.get(), value) | 828 | self.assertEqual(variable.get(), value) |
4241 | 829 | variable.set(u"0609f76b-878f-4546-baf5-c1b135e8de72", from_db=True) | 829 | variable.set("0609f76b-878f-4546-baf5-c1b135e8de72", from_db=True) |
4242 | 830 | self.assertEqual(variable.get(), value) | 830 | self.assertEqual(variable.get(), value) |
4243 | 831 | 831 | ||
4244 | 832 | # Some other representations for UUID values. | 832 | # Some other representations for UUID values. |
4245 | @@ -836,7 +836,7 @@ | |||
4246 | 836 | self.assertEqual(variable.get(), value) | 836 | self.assertEqual(variable.get(), value) |
4247 | 837 | 837 | ||
4248 | 838 | 838 | ||
4250 | 839 | class EncodedValueVariableTestMixin(object): | 839 | class EncodedValueVariableTestMixin: |
4251 | 840 | 840 | ||
4252 | 841 | encoding = None | 841 | encoding = None |
4253 | 842 | variable_type = None | 842 | variable_type = None |
4254 | @@ -925,7 +925,7 @@ | |||
4255 | 925 | # JSONVariable._dumps() works around text/bytes handling issues in | 925 | # JSONVariable._dumps() works around text/bytes handling issues in |
4256 | 926 | # json. | 926 | # json. |
4257 | 927 | variable = self.variable_type() | 927 | variable = self.variable_type() |
4259 | 928 | variable.set({u"a": 1}) | 928 | variable.set({"a": 1}) |
4260 | 929 | self.assertTrue(isinstance(variable.get(to_db=True), str)) | 929 | self.assertTrue(isinstance(variable.get(to_db=True), str)) |
4261 | 930 | 930 | ||
4262 | 931 | 931 | ||
4263 | 932 | 932 | ||
4264 | === modified file 'storm/tests/wsgi.py' | |||
4265 | --- storm/tests/wsgi.py 2024-03-04 10:59:55 +0000 | |||
4266 | +++ storm/tests/wsgi.py 2024-03-13 16:26:38 +0000 | |||
4267 | @@ -105,7 +105,7 @@ | |||
4268 | 105 | self.assertEqual(timeline, found_timeline) | 105 | self.assertEqual(timeline, found_timeline) |
4269 | 106 | 106 | ||
4270 | 107 | 107 | ||
4272 | 108 | class FakeTimeline(object): | 108 | class FakeTimeline: |
4273 | 109 | """A fake Timeline. | 109 | """A fake Timeline. |
4274 | 110 | 110 | ||
4275 | 111 | We need this because we can't use plain object instances as they can't be | 111 | We need this because we can't use plain object instances as they can't be |
4276 | 112 | 112 | ||
4277 | === modified file 'storm/tests/zope/adapters.py' | |||
4278 | --- storm/tests/zope/adapters.py 2024-03-04 10:59:55 +0000 | |||
4279 | +++ storm/tests/zope/adapters.py 2024-03-13 16:26:38 +0000 | |||
4280 | @@ -31,7 +31,7 @@ | |||
4281 | 31 | from storm.zope.interfaces import IResultSet, ISQLObjectResultSet | 31 | from storm.zope.interfaces import IResultSet, ISQLObjectResultSet |
4282 | 32 | 32 | ||
4283 | 33 | @implementer(ISQLObjectResultSet) | 33 | @implementer(ISQLObjectResultSet) |
4285 | 34 | class TestSQLObjectResultSet(object): | 34 | class TestSQLObjectResultSet: |
4286 | 35 | _result_set = EmptyResultSet() | 35 | _result_set = EmptyResultSet() |
4287 | 36 | 36 | ||
4288 | 37 | 37 | ||
4289 | 38 | 38 | ||
4290 | === modified file 'storm/tests/zope/testing.py' | |||
4291 | --- storm/tests/zope/testing.py 2024-03-04 10:59:55 +0000 | |||
4292 | +++ storm/tests/zope/testing.py 2024-03-13 16:26:38 +0000 | |||
4293 | @@ -53,7 +53,7 @@ | |||
4294 | 53 | return has_transaction and has_zope_component and has_testresources | 53 | return has_transaction and has_zope_component and has_testresources |
4295 | 54 | 54 | ||
4296 | 55 | def setUp(self): | 55 | def setUp(self): |
4298 | 56 | super(ZStormResourceManagerTest, self).setUp() | 56 | super().setUp() |
4299 | 57 | package_dir = self.makeDir() | 57 | package_dir = self.makeDir() |
4300 | 58 | sys.path.append(package_dir) | 58 | sys.path.append(package_dir) |
4301 | 59 | self.patch_dir = os.path.join(package_dir, "patch_package") | 59 | self.patch_dir = os.path.join(package_dir, "patch_package") |
4302 | @@ -77,7 +77,7 @@ | |||
4303 | 77 | global_zstorm._reset() | 77 | global_zstorm._reset() |
4304 | 78 | del sys.modules["patch_package"] | 78 | del sys.modules["patch_package"] |
4305 | 79 | sys.modules.pop("patch_package.patch_1", None) | 79 | sys.modules.pop("patch_package.patch_1", None) |
4307 | 80 | super(ZStormResourceManagerTest, self).tearDown() | 80 | super().tearDown() |
4308 | 81 | 81 | ||
4309 | 82 | def test_make(self): | 82 | def test_make(self): |
4310 | 83 | """ | 83 | """ |
4311 | @@ -182,7 +182,7 @@ | |||
4312 | 182 | L{ZStormResourceManager.clean} tries to flush the stores to make sure | 182 | L{ZStormResourceManager.clean} tries to flush the stores to make sure |
4313 | 183 | that they are all in a consistent state. | 183 | that they are all in a consistent state. |
4314 | 184 | """ | 184 | """ |
4316 | 185 | class Test(object): | 185 | class Test: |
4317 | 186 | __storm_table__ = "test" | 186 | __storm_table__ = "test" |
4318 | 187 | foo = Unicode() | 187 | foo = Unicode() |
4319 | 188 | bar = Int(primary=True) | 188 | bar = Int(primary=True) |
4320 | @@ -193,8 +193,8 @@ | |||
4321 | 193 | 193 | ||
4322 | 194 | zstorm = self.resource.make([]) | 194 | zstorm = self.resource.make([]) |
4323 | 195 | store = zstorm.get("test") | 195 | store = zstorm.get("test") |
4326 | 196 | store.add(Test(u"data", 1)) | 196 | store.add(Test("data", 1)) |
4327 | 197 | store.add(Test(u"data", 2)) | 197 | store.add(Test("data", 2)) |
4328 | 198 | self.assertRaises(IntegrityError, self.resource.clean, zstorm) | 198 | self.assertRaises(IntegrityError, self.resource.clean, zstorm) |
4329 | 199 | 199 | ||
4330 | 200 | def test_clean_delete(self): | 200 | def test_clean_delete(self): |
4331 | @@ -227,7 +227,7 @@ | |||
4332 | 227 | L{ZStormResourceManager.clean} clears the alive cache before | 227 | L{ZStormResourceManager.clean} clears the alive cache before |
4333 | 228 | aborting the transaction. | 228 | aborting the transaction. |
4334 | 229 | """ | 229 | """ |
4336 | 230 | class Test(object): | 230 | class Test: |
4337 | 231 | __storm_table__ = "test" | 231 | __storm_table__ = "test" |
4338 | 232 | bar = Int(primary=True) | 232 | bar = Int(primary=True) |
4339 | 233 | 233 | ||
4340 | @@ -405,7 +405,7 @@ | |||
4341 | 405 | self.makeFile(path=os.path.join(self.patch_dir, "patch_2.py"), | 405 | self.makeFile(path=os.path.join(self.patch_dir, "patch_2.py"), |
4342 | 406 | content="def apply(store): pass") | 406 | content="def apply(store): pass") |
4343 | 407 | 407 | ||
4345 | 408 | class FakeStat(object): | 408 | class FakeStat: |
4346 | 409 | st_mtime = os.stat(self.patch_dir).st_mtime + 1 | 409 | st_mtime = os.stat(self.patch_dir).st_mtime + 1 |
4347 | 410 | 410 | ||
4348 | 411 | stat_mock = self.mocker.replace(os.stat) | 411 | stat_mock = self.mocker.replace(os.stat) |
4349 | 412 | 412 | ||
4350 | === modified file 'storm/tests/zope/zstorm.py' | |||
4351 | --- storm/tests/zope/zstorm.py 2024-03-04 10:59:55 +0000 | |||
4352 | +++ storm/tests/zope/zstorm.py 2024-03-13 16:26:38 +0000 | |||
4353 | @@ -136,8 +136,7 @@ | |||
4354 | 136 | stores.append((name, store)) | 136 | stores.append((name, store)) |
4355 | 137 | self.assertEqual(len(stores), 3) | 137 | self.assertEqual(len(stores), 3) |
4356 | 138 | self.assertEqual(set(stores), | 138 | self.assertEqual(set(stores), |
4359 | 139 | set([(None, store1), (None, store2), | 139 | {(None, store1), (None, store2), ("name", store3)}) |
4358 | 140 | ("name", store3)])) | ||
4360 | 141 | 140 | ||
4361 | 142 | def test_get_name(self): | 141 | def test_get_name(self): |
4362 | 143 | store = self.zstorm.create("name", "sqlite:") | 142 | store = self.zstorm.create("name", "sqlite:") |
4363 | 144 | 143 | ||
4364 | === modified file 'storm/tracer.py' | |||
4365 | --- storm/tracer.py 2024-03-04 10:59:55 +0000 | |||
4366 | +++ storm/tracer.py 2024-03-13 16:26:38 +0000 | |||
4367 | @@ -9,7 +9,7 @@ | |||
4368 | 9 | from storm.expr import Variable | 9 | from storm.expr import Variable |
4369 | 10 | 10 | ||
4370 | 11 | 11 | ||
4372 | 12 | class DebugTracer(object): | 12 | class DebugTracer: |
4373 | 13 | 13 | ||
4374 | 14 | def __init__(self, stream=None): | 14 | def __init__(self, stream=None): |
4375 | 15 | if stream is None: | 15 | if stream is None: |
4376 | @@ -53,7 +53,7 @@ | |||
4377 | 53 | self._stream.flush() | 53 | self._stream.flush() |
4378 | 54 | 54 | ||
4379 | 55 | 55 | ||
4381 | 56 | class TimeoutTracer(object): | 56 | class TimeoutTracer: |
4382 | 57 | """Provide a timeout facility for connections to prevent rogue operations. | 57 | """Provide a timeout facility for connections to prevent rogue operations. |
4383 | 58 | 58 | ||
4384 | 59 | This tracer must be subclassed by backend-specific implementations that | 59 | This tracer must be subclassed by backend-specific implementations that |
4385 | @@ -141,7 +141,7 @@ | |||
4386 | 141 | % self.__class__.__name__) | 141 | % self.__class__.__name__) |
4387 | 142 | 142 | ||
4388 | 143 | 143 | ||
4390 | 144 | class BaseStatementTracer(object): | 144 | class BaseStatementTracer: |
4391 | 145 | """Storm tracer base class that does query interpolation.""" | 145 | """Storm tracer base class that does query interpolation.""" |
4392 | 146 | 146 | ||
4393 | 147 | def connection_raw_execute(self, connection, raw_cursor, | 147 | def connection_raw_execute(self, connection, raw_cursor, |
4394 | @@ -207,7 +207,7 @@ | |||
4395 | 207 | on the connection object. If no name has been assigned, '<unknown>' | 207 | on the connection object. If no name has been assigned, '<unknown>' |
4396 | 208 | is used instead. | 208 | is used instead. |
4397 | 209 | """ | 209 | """ |
4399 | 210 | super(TimelineTracer, self).__init__() | 210 | super().__init__() |
4400 | 211 | self.timeline_factory = timeline_factory | 211 | self.timeline_factory = timeline_factory |
4401 | 212 | self.prefix = prefix | 212 | self.prefix = prefix |
4402 | 213 | # Stores the action in progress in a given thread. | 213 | # Stores the action in progress in a given thread. |
4403 | 214 | 214 | ||
4404 | === modified file 'storm/twisted/testing.py' | |||
4405 | --- storm/twisted/testing.py 2024-03-04 10:59:55 +0000 | |||
4406 | +++ storm/twisted/testing.py 2024-03-13 16:26:38 +0000 | |||
4407 | @@ -4,7 +4,7 @@ | |||
4408 | 4 | from storm.twisted.transact import Transactor | 4 | from storm.twisted.transact import Transactor |
4409 | 5 | 5 | ||
4410 | 6 | 6 | ||
4412 | 7 | class FakeThreadPool(object): | 7 | class FakeThreadPool: |
4413 | 8 | """ | 8 | """ |
4414 | 9 | A fake L{twisted.python.threadpool.ThreadPool}, running functions inside | 9 | A fake L{twisted.python.threadpool.ThreadPool}, running functions inside |
4415 | 10 | the main thread instead for easing tests. | 10 | the main thread instead for easing tests. |
4416 | @@ -21,7 +21,7 @@ | |||
4417 | 21 | onResult(success, result) | 21 | onResult(success, result) |
4418 | 22 | 22 | ||
4419 | 23 | 23 | ||
4421 | 24 | class FakeTransaction(object): | 24 | class FakeTransaction: |
4422 | 25 | 25 | ||
4423 | 26 | def commit(self): | 26 | def commit(self): |
4424 | 27 | pass | 27 | pass |
4425 | 28 | 28 | ||
4426 | === modified file 'storm/twisted/transact.py' | |||
4427 | --- storm/twisted/transact.py 2024-03-04 10:59:55 +0000 | |||
4428 | +++ storm/twisted/transact.py 2024-03-13 16:26:38 +0000 | |||
4429 | @@ -20,7 +20,7 @@ | |||
4430 | 20 | pass | 20 | pass |
4431 | 21 | 21 | ||
4432 | 22 | 22 | ||
4434 | 23 | class Transactor(object): | 23 | class Transactor: |
4435 | 24 | """Run in a thread code that needs to interact with the database. | 24 | """Run in a thread code that needs to interact with the database. |
4436 | 25 | 25 | ||
4437 | 26 | This class makes sure that code interacting with the database is run | 26 | This class makes sure that code interacting with the database is run |
4438 | @@ -105,7 +105,7 @@ | |||
4439 | 105 | return result | 105 | return result |
4440 | 106 | 106 | ||
4441 | 107 | 107 | ||
4443 | 108 | class RetryContext(object): | 108 | class RetryContext: |
4444 | 109 | """Hold details about a function that is going to be retried. | 109 | """Hold details about a function that is going to be retried. |
4445 | 110 | 110 | ||
4446 | 111 | @ivar function: The function that is going to be retried. | 111 | @ivar function: The function that is going to be retried. |
4447 | 112 | 112 | ||
4448 | === modified file 'storm/tz.py' | |||
4449 | --- storm/tz.py 2024-03-04 10:59:55 +0000 | |||
4450 | +++ storm/tz.py 2024-03-13 16:26:38 +0000 | |||
4451 | @@ -149,7 +149,7 @@ | |||
4452 | 149 | 149 | ||
4453 | 150 | __reduce__ = object.__reduce__ | 150 | __reduce__ = object.__reduce__ |
4454 | 151 | 151 | ||
4456 | 152 | class _ttinfo(object): | 152 | class _ttinfo: |
4457 | 153 | __slots__ = ["offset", "delta", "isdst", "abbr", "isstd", "isgmt"] | 153 | __slots__ = ["offset", "delta", "isdst", "abbr", "isstd", "isgmt"] |
4458 | 154 | 154 | ||
4459 | 155 | def __init__(self): | 155 | def __init__(self): |
4460 | @@ -889,7 +889,7 @@ | |||
4461 | 889 | try: | 889 | try: |
4462 | 890 | tz = tzfile(filepath) | 890 | tz = tzfile(filepath) |
4463 | 891 | break | 891 | break |
4465 | 892 | except (IOError, OSError, ValueError): | 892 | except (OSError, ValueError): |
4466 | 893 | pass | 893 | pass |
4467 | 894 | else: | 894 | else: |
4468 | 895 | tz = tzlocal() | 895 | tz = tzlocal() |
4469 | @@ -911,7 +911,7 @@ | |||
4470 | 911 | try: | 911 | try: |
4471 | 912 | tz = tzfile(filepath) | 912 | tz = tzfile(filepath) |
4472 | 913 | break | 913 | break |
4474 | 914 | except (IOError, OSError, ValueError): | 914 | except (OSError, ValueError): |
4475 | 915 | pass | 915 | pass |
4476 | 916 | else: | 916 | else: |
4477 | 917 | tz = None | 917 | tz = None |
4478 | 918 | 918 | ||
4479 | === modified file 'storm/uri.py' | |||
4480 | --- storm/uri.py 2024-03-04 10:59:55 +0000 | |||
4481 | +++ storm/uri.py 2024-03-13 16:26:38 +0000 | |||
4482 | @@ -23,7 +23,7 @@ | |||
4483 | 23 | from storm.exceptions import URIError | 23 | from storm.exceptions import URIError |
4484 | 24 | 24 | ||
4485 | 25 | 25 | ||
4487 | 26 | class URI(object): | 26 | class URI: |
4488 | 27 | """A representation of a Uniform Resource Identifier (URI). | 27 | """A representation of a Uniform Resource Identifier (URI). |
4489 | 28 | 28 | ||
4490 | 29 | This is intended exclusively for database connection URIs. | 29 | This is intended exclusively for database connection URIs. |
4491 | 30 | 30 | ||
4492 | === modified file 'storm/variables.py' | |||
4493 | --- storm/variables.py 2024-03-04 10:59:55 +0000 | |||
4494 | +++ storm/variables.py 2024-03-13 16:26:38 +0000 | |||
4495 | @@ -54,7 +54,7 @@ | |||
4496 | 54 | ] | 54 | ] |
4497 | 55 | 55 | ||
4498 | 56 | 56 | ||
4500 | 57 | class LazyValue(object): | 57 | class LazyValue: |
4501 | 58 | """Marker to be used as a base class on lazily evaluated values.""" | 58 | """Marker to be used as a base class on lazily evaluated values.""" |
4502 | 59 | __slots__ = () | 59 | __slots__ = () |
4503 | 60 | 60 | ||
4504 | @@ -79,7 +79,7 @@ | |||
4505 | 79 | VariableFactory = partial | 79 | VariableFactory = partial |
4506 | 80 | 80 | ||
4507 | 81 | 81 | ||
4509 | 82 | class Variable(object): | 82 | class Variable: |
4510 | 83 | """Basic representation of a database value in Python. | 83 | """Basic representation of a database value in Python. |
4511 | 84 | 84 | ||
4512 | 85 | @type column: L{storm.expr.Column} | 85 | @type column: L{storm.expr.Column} |
4513 | @@ -394,7 +394,7 @@ | |||
4514 | 394 | 394 | ||
4515 | 395 | def __init__(self, *args, **kwargs): | 395 | def __init__(self, *args, **kwargs): |
4516 | 396 | self._tzinfo = kwargs.pop("tzinfo", None) | 396 | self._tzinfo = kwargs.pop("tzinfo", None) |
4518 | 397 | super(DateTimeVariable, self).__init__(*args, **kwargs) | 397 | super().__init__(*args, **kwargs) |
4519 | 398 | 398 | ||
4520 | 399 | def parse_set(self, value, from_db): | 399 | def parse_set(self, value, from_db): |
4521 | 400 | if from_db: | 400 | if from_db: |
4522 | @@ -579,7 +579,7 @@ | |||
4523 | 579 | def get(self, default=None, to_db=False): | 579 | def get(self, default=None, to_db=False): |
4524 | 580 | if self._event_system is not None: | 580 | if self._event_system is not None: |
4525 | 581 | self._event_system.hook("flush", self._detect_changes) | 581 | self._event_system.hook("flush", self._detect_changes) |
4527 | 582 | return super(MutableValueVariable, self).get(default, to_db) | 582 | return super().get(default, to_db) |
4528 | 583 | 583 | ||
4529 | 584 | def set(self, value, from_db=False): | 584 | def set(self, value, from_db=False): |
4530 | 585 | if self._event_system is not None: | 585 | if self._event_system is not None: |
4531 | @@ -587,7 +587,7 @@ | |||
4532 | 587 | self._event_system.unhook("flush", self._detect_changes) | 587 | self._event_system.unhook("flush", self._detect_changes) |
4533 | 588 | else: | 588 | else: |
4534 | 589 | self._event_system.hook("flush", self._detect_changes) | 589 | self._event_system.hook("flush", self._detect_changes) |
4536 | 590 | super(MutableValueVariable, self).set(value, from_db) | 590 | super().set(value, from_db) |
4537 | 591 | 591 | ||
4538 | 592 | 592 | ||
4539 | 593 | class EncodedValueVariable(MutableValueVariable): | 593 | class EncodedValueVariable(MutableValueVariable): |
4540 | 594 | 594 | ||
4541 | === modified file 'storm/xid.py' | |||
4542 | --- storm/xid.py 2024-03-04 10:59:55 +0000 | |||
4543 | +++ storm/xid.py 2024-03-13 16:26:38 +0000 | |||
4544 | @@ -19,7 +19,7 @@ | |||
4545 | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
4546 | 20 | # | 20 | # |
4547 | 21 | 21 | ||
4549 | 22 | class Xid(object): | 22 | class Xid: |
4550 | 23 | """ | 23 | """ |
4551 | 24 | Represent a transaction identifier compliant with the XA specification. | 24 | Represent a transaction identifier compliant with the XA specification. |
4552 | 25 | """ | 25 | """ |
4553 | 26 | 26 | ||
4554 | === modified file 'storm/zope/metadirectives.py' | |||
4555 | --- storm/zope/metadirectives.py 2024-03-04 10:59:55 +0000 | |||
4556 | +++ storm/zope/metadirectives.py 2024-03-13 16:26:38 +0000 | |||
4557 | @@ -24,5 +24,5 @@ | |||
4558 | 24 | 24 | ||
4559 | 25 | class IStoreDirective(Interface): | 25 | class IStoreDirective(Interface): |
4560 | 26 | 26 | ||
4563 | 27 | name = TextLine(title=u"Name", description=u"Store name") | 27 | name = TextLine(title="Name", description="Store name") |
4564 | 28 | uri = TextLine(title=u"URI", description=u"Database URI") | 28 | uri = TextLine(title="URI", description="Database URI") |
4565 | 29 | 29 | ||
4566 | === modified file 'storm/zope/schema.py' | |||
4567 | --- storm/zope/schema.py 2024-03-04 10:59:55 +0000 | |||
4568 | +++ storm/zope/schema.py 2024-03-13 16:26:38 +0000 | |||
4569 | @@ -24,7 +24,7 @@ | |||
4570 | 24 | from storm.schema import Schema | 24 | from storm.schema import Schema |
4571 | 25 | 25 | ||
4572 | 26 | 26 | ||
4574 | 27 | class ZCommitter(object): | 27 | class ZCommitter: |
4575 | 28 | """A L{Schema} committer that uses Zope's transaction manager.""" | 28 | """A L{Schema} committer that uses Zope's transaction manager.""" |
4576 | 29 | 29 | ||
4577 | 30 | def commit(self): | 30 | def commit(self): |
4578 | @@ -39,5 +39,4 @@ | |||
4579 | 39 | 39 | ||
4580 | 40 | def __init__(self, creates, drops, deletes, patch_package): | 40 | def __init__(self, creates, drops, deletes, patch_package): |
4581 | 41 | committer = ZCommitter() | 41 | committer = ZCommitter() |
4584 | 42 | super(ZSchema, self).__init__(creates, drops, deletes, patch_package, | 42 | super().__init__(creates, drops, deletes, patch_package, committer) |
4583 | 43 | committer) | ||
4585 | 44 | 43 | ||
4586 | === modified file 'storm/zope/testing.py' | |||
4587 | --- storm/zope/testing.py 2024-03-04 10:59:55 +0000 | |||
4588 | +++ storm/zope/testing.py 2024-03-13 16:26:38 +0000 | |||
4589 | @@ -70,7 +70,7 @@ | |||
4590 | 70 | vertical_patching = True | 70 | vertical_patching = True |
4591 | 71 | 71 | ||
4592 | 72 | def __init__(self, databases): | 72 | def __init__(self, databases): |
4594 | 73 | super(ZStormResourceManager, self).__init__() | 73 | super().__init__() |
4595 | 74 | self._databases = databases | 74 | self._databases = databases |
4596 | 75 | self._zstorm = None | 75 | self._zstorm = None |
4597 | 76 | self._schema_zstorm = None | 76 | self._schema_zstorm = None |
4598 | 77 | 77 | ||
4599 | === modified file 'storm/zope/zstorm.py' | |||
4600 | --- storm/zope/zstorm.py 2024-03-04 10:59:55 +0000 | |||
4601 | +++ storm/zope/zstorm.py 2024-03-13 16:26:38 +0000 | |||
4602 | @@ -45,7 +45,7 @@ | |||
4603 | 45 | 45 | ||
4604 | 46 | 46 | ||
4605 | 47 | @implementer(IZStorm) | 47 | @implementer(IZStorm) |
4607 | 48 | class ZStorm(object): | 48 | class ZStorm: |
4608 | 49 | """A utility which integrates Storm with Zope. | 49 | """A utility which integrates Storm with Zope. |
4609 | 50 | 50 | ||
4610 | 51 | Typically, applications will register stores using ZCML similar | 51 | Typically, applications will register stores using ZCML similar |
4611 | @@ -255,7 +255,7 @@ | |||
4612 | 255 | 255 | ||
4613 | 256 | 256 | ||
4614 | 257 | @implementer(IDataManager) | 257 | @implementer(IDataManager) |
4616 | 258 | class StoreDataManager(object): | 258 | class StoreDataManager: |
4617 | 259 | """An L{IDataManager} implementation for C{ZStorm}.""" | 259 | """An L{IDataManager} implementation for C{ZStorm}.""" |
4618 | 260 | 260 | ||
4619 | 261 | def __init__(self, store, zstorm): | 261 | def __init__(self, store, zstorm): |