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