Merge lp:~cjwatson/storm/pyupgrade into lp:storm

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
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-percent-format`.

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
=== modified file 'storm/__init__.py'
--- storm/__init__.py 2024-03-04 10:59:55 +0000
+++ storm/__init__.py 2024-03-13 16:26:38 +0000
@@ -32,7 +32,7 @@
32version_info = tuple([int(x) for x in version.split(".")])32version_info = tuple([int(x) for x in version.split(".")])
3333
3434
35class UndefType(object):35class UndefType:
3636
37 def __repr__(self):37 def __repr__(self):
38 return "Undef"38 return "Undef"
3939
=== modified file 'storm/cache.py'
--- storm/cache.py 2024-03-04 10:59:55 +0000
+++ storm/cache.py 2024-03-13 16:26:38 +0000
@@ -1,7 +1,7 @@
1import itertools1import itertools
22
33
4class Cache(object):4class Cache:
5 """Prevents recently used objects from being deallocated.5 """Prevents recently used objects from being deallocated.
66
7 This prevents recently used objects from being deallocated by Python7 This prevents recently used objects from being deallocated by Python
@@ -69,7 +69,7 @@
69 return list(self._order)69 return list(self._order)
7070
7171
72class GenerationalCache(object):72class GenerationalCache:
73 """Generational replacement for Storm's LRU cache.73 """Generational replacement for Storm's LRU cache.
7474
75 This cache approximates LRU without keeping exact track. Instead,75 This cache approximates LRU without keeping exact track. Instead,
7676
=== modified file 'storm/database.py'
--- storm/database.py 2024-03-04 10:59:55 +0000
+++ storm/database.py 2024-03-13 16:26:38 +0000
@@ -49,7 +49,7 @@
49STATE_RECONNECT = 349STATE_RECONNECT = 3
5050
5151
52class Result(object):52class Result:
53 """A representation of the results from a single SQL statement."""53 """A representation of the results from a single SQL statement."""
5454
55 _closed = False55 _closed = False
@@ -164,12 +164,12 @@
164 return row164 return row
165165
166166
167class CursorWrapper(object):167class CursorWrapper:
168 """A DB-API cursor, wrapping exceptions as StormError instances."""168 """A DB-API cursor, wrapping exceptions as StormError instances."""
169169
170 def __init__(self, cursor, database):170 def __init__(self, cursor, database):
171 super(CursorWrapper, self).__setattr__('_cursor', cursor)171 super().__setattr__('_cursor', cursor)
172 super(CursorWrapper, self).__setattr__('_database', database)172 super().__setattr__('_database', database)
173173
174 def __getattr__(self, name):174 def __getattr__(self, name):
175 attr = getattr(self._cursor, name)175 attr = getattr(self._cursor, name)
@@ -188,8 +188,7 @@
188188
189 def __iter__(self):189 def __iter__(self):
190 with wrap_exceptions(self._database):190 with wrap_exceptions(self._database):
191 for item in self._cursor:191 yield from self._cursor
192 yield item
193192
194 def __enter__(self):193 def __enter__(self):
195 return self194 return self
@@ -199,7 +198,7 @@
199 self.close()198 self.close()
200199
201200
202class ConnectionWrapper(object):201class ConnectionWrapper:
203 """A DB-API connection, wrapping exceptions as StormError instances."""202 """A DB-API connection, wrapping exceptions as StormError instances."""
204203
205 def __init__(self, connection, database):204 def __init__(self, connection, database):
@@ -236,7 +235,7 @@
236 return CursorWrapper(self._connection.cursor(), self._database)235 return CursorWrapper(self._connection.cursor(), self._database)
237236
238237
239class Connection(object):238class Connection:
240 """A connection to a database.239 """A connection to a database.
241240
242 @cvar result_factory: A callable which takes this L{Connection}241 @cvar result_factory: A callable which takes this L{Connection}
@@ -544,7 +543,7 @@
544 """543 """
545544
546545
547class Database(object):546class Database:
548 """A database that can be connected to.547 """A database that can be connected to.
549548
550 This should be subclassed for individual database backends.549 This should be subclassed for individual database backends.
551550
=== modified file 'storm/databases/__init__.py'
--- storm/databases/__init__.py 2024-03-04 10:59:55 +0000
+++ storm/databases/__init__.py 2024-03-13 16:26:38 +0000
@@ -20,7 +20,7 @@
20#20#
2121
2222
23class Dummy(object):23class Dummy:
24 """Magic "infectious" class.24 """Magic "infectious" class.
2525
26 This class simplifies nice errors on the creation of26 This class simplifies nice errors on the creation of
2727
=== modified file 'storm/databases/mysql.py'
--- storm/databases/mysql.py 2024-03-04 10:59:55 +0000
+++ storm/databases/mysql.py 2024-03-13 16:26:38 +0000
@@ -139,7 +139,7 @@
139 _converters = None139 _converters = None
140140
141 def __init__(self, uri):141 def __init__(self, uri):
142 super(MySQL, self).__init__(uri)142 super().__init__(uri)
143 if MySQLdb is dummy:143 if MySQLdb is dummy:
144 raise DatabaseModuleError("'MySQLdb' module not found")144 raise DatabaseModuleError("'MySQLdb' module not found")
145 self._connect_kwargs = {}145 self._connect_kwargs = {}
146146
=== modified file 'storm/databases/postgres.py'
--- storm/databases/postgres.py 2024-03-04 16:33:02 +0000
+++ storm/databases/postgres.py 2024-03-13 16:26:38 +0000
@@ -369,7 +369,7 @@
369 _version = None369 _version = None
370370
371 def __init__(self, uri):371 def __init__(self, uri):
372 super(Postgres, self).__init__(uri)372 super().__init__(uri)
373 if psycopg2 is dummy:373 if psycopg2 is dummy:
374 raise DatabaseModuleError(374 raise DatabaseModuleError(
375 "'psycopg2' >= %s not found. Found %s."375 "'psycopg2' >= %s not found. Found %s."
@@ -400,15 +400,14 @@
400 _psycopg_error_attributes = tuple(_psycopg_error_attributes)400 _psycopg_error_attributes = tuple(_psycopg_error_attributes)
401401
402 def _make_combined_exception_type(self, wrapper_type, dbapi_type):402 def _make_combined_exception_type(self, wrapper_type, dbapi_type):
403 combined_type = super(Postgres, self)._make_combined_exception_type(403 combined_type = super()._make_combined_exception_type(
404 wrapper_type, dbapi_type)404 wrapper_type, dbapi_type)
405 for name in self._psycopg_error_attributes:405 for name in self._psycopg_error_attributes:
406 setattr(combined_type, name, lambda err: getattr(err, "_" + name))406 setattr(combined_type, name, lambda err: getattr(err, "_" + name))
407 return combined_type407 return combined_type
408408
409 def _wrap_exception(self, wrapper_type, exception):409 def _wrap_exception(self, wrapper_type, exception):
410 wrapped = super(Postgres, self)._wrap_exception(410 wrapped = super()._wrap_exception(wrapper_type, exception)
411 wrapper_type, exception)
412 for name in self._psycopg_error_attributes:411 for name in self._psycopg_error_attributes:
413 setattr(wrapped, "_" + name, getattr(exception, name))412 setattr(wrapped, "_" + name, getattr(exception, name))
414 return wrapped413 return wrapped
415414
=== modified file 'storm/databases/sqlite.py'
--- storm/databases/sqlite.py 2024-03-04 10:59:55 +0000
+++ storm/databases/sqlite.py 2024-03-13 16:26:38 +0000
@@ -163,7 +163,7 @@
163 _exception_module = sqlite163 _exception_module = sqlite
164164
165 def __init__(self, uri):165 def __init__(self, uri):
166 super(SQLite, self).__init__(uri)166 super().__init__(uri)
167 if sqlite is dummy:167 if sqlite is dummy:
168 raise DatabaseModuleError("'pysqlite2' module not found")168 raise DatabaseModuleError("'pysqlite2' module not found")
169 self._filename = uri.database or ":memory:"169 self._filename = uri.database or ":memory:"
170170
=== modified file 'storm/docs/conf.py'
--- storm/docs/conf.py 2020-05-26 10:28:24 +0000
+++ storm/docs/conf.py 2024-03-13 16:26:38 +0000
@@ -1,5 +1,3 @@
1# -*- coding: utf-8 -*-
2#
3# Configuration file for the Sphinx documentation builder.1# Configuration file for the Sphinx documentation builder.
4#2#
5# This file does only contain a selection of the most common options. For a3# This file does only contain a selection of the most common options. For a
64
=== modified file 'storm/event.py'
--- storm/event.py 2024-03-04 10:59:55 +0000
+++ storm/event.py 2024-03-13 16:26:38 +0000
@@ -26,7 +26,7 @@
26__all__ = ["EventSystem"]26__all__ = ["EventSystem"]
2727
2828
29class EventSystem(object):29class EventSystem:
30 """A system for managing hooks that are called when events are emitted.30 """A system for managing hooks that are called when events are emitted.
3131
32 Hooks are callables that take the event system C{owner} as their first32 Hooks are callables that take the event system C{owner} as their first
3333
=== modified file 'storm/expr.py'
--- storm/expr.py 2024-03-04 10:59:55 +0000
+++ storm/expr.py 2024-03-13 16:26:38 +0000
@@ -45,7 +45,7 @@
45 return decorator45 return decorator
4646
4747
48class Compile(object):48class Compile:
49 """Compiler based on the concept of generic functions."""49 """Compiler based on the concept of generic functions."""
5050
51 def __init__(self, parent=None):51 def __init__(self, parent=None):
@@ -145,7 +145,7 @@
145 return "(%s)" % statement145 return "(%s)" % statement
146 return statement146 return statement
147147
148 def __call__(self, expr, state=None, join=u", ", raw=False, token=False):148 def __call__(self, expr, state=None, join=", ", raw=False, token=False):
149 """Compile the given expression into a SQL statement.149 """Compile the given expression into a SQL statement.
150150
151 @param expr: The expression to compile.151 @param expr: The expression to compile.
@@ -217,7 +217,7 @@
217 return namespace['closure'](state.parameters, bool)217 return namespace['closure'](state.parameters, bool)
218218
219219
220class State(object):220class State:
221 """All the data necessary during compilation of an expression.221 """All the data necessary during compilation of an expression.
222222
223 @ivar aliases: Dict of L{Column} instances to L{Alias} instances,223 @ivar aliases: Dict of L{Column} instances to L{Alias} instances,
@@ -276,7 +276,7 @@
276# --------------------------------------------------------------------276# --------------------------------------------------------------------
277# Expression contexts277# Expression contexts
278278
279class Context(object):279class Context:
280 """280 """
281 An object used to specify the nature of expected SQL expressions281 An object used to specify the nature of expected SQL expressions
282 being compiled in a given context.282 being compiled in a given context.
@@ -395,13 +395,13 @@
395# A translation table that can escape a unicode string for use in a395# A translation table that can escape a unicode string for use in a
396# Like() expression that uses "!" as the escape character.396# Like() expression that uses "!" as the escape character.
397like_escape = {397like_escape = {
398 ord(u"!"): u"!!",398 ord("!"): "!!",
399 ord(u"_"): u"!_",399 ord("_"): "!_",
400 ord(u"%"): u"!%"400 ord("%"): "!%"
401 }401 }
402402
403403
404class Comparable(object):404class Comparable:
405 __slots__ = ()405 __slots__ = ()
406 __hash__ = object.__hash__406 __hash__ = object.__hash__
407407
@@ -511,20 +511,20 @@
511 def startswith(self, prefix, case_sensitive=None):511 def startswith(self, prefix, case_sensitive=None):
512 if not isinstance(prefix, str):512 if not isinstance(prefix, str):
513 raise ExprError("Expected text argument, got %r" % type(prefix))513 raise ExprError("Expected text argument, got %r" % type(prefix))
514 pattern = prefix.translate(like_escape) + u"%"514 pattern = prefix.translate(like_escape) + "%"
515 return Like(self, pattern, u"!", case_sensitive)515 return Like(self, pattern, "!", case_sensitive)
516516
517 def endswith(self, suffix, case_sensitive=None):517 def endswith(self, suffix, case_sensitive=None):
518 if not isinstance(suffix, str):518 if not isinstance(suffix, str):
519 raise ExprError("Expected text argument, got %r" % type(suffix))519 raise ExprError("Expected text argument, got %r" % type(suffix))
520 pattern = u"%" + suffix.translate(like_escape)520 pattern = "%" + suffix.translate(like_escape)
521 return Like(self, pattern, u"!", case_sensitive)521 return Like(self, pattern, "!", case_sensitive)
522522
523 def contains_string(self, substring, case_sensitive=None):523 def contains_string(self, substring, case_sensitive=None):
524 if not isinstance(substring, str):524 if not isinstance(substring, str):
525 raise ExprError("Expected text argument, got %r" % type(substring))525 raise ExprError("Expected text argument, got %r" % type(substring))
526 pattern = u"%" + substring.translate(like_escape) + u"%"526 pattern = "%" + substring.translate(like_escape) + "%"
527 return Like(self, pattern, u"!", case_sensitive)527 return Like(self, pattern, "!", case_sensitive)
528528
529529
530class ComparableExpr(Expr, Comparable):530class ComparableExpr(Expr, Comparable):
@@ -584,7 +584,7 @@
584 break584 break
585 else:585 else:
586 if tables is state.auto_tables:586 if tables is state.auto_tables:
587 tables = set(compile(table, state, token=True) for table in tables)587 tables = {compile(table, state, token=True) for table in tables}
588 return ", ".join(sorted(tables))588 return ", ".join(sorted(tables))
589 else:589 else:
590 return compile(tables, state, token=True)590 return compile(tables, state, token=True)
591591
=== modified file 'storm/info.py'
--- storm/info.py 2024-03-04 10:59:55 +0000
+++ storm/info.py 2024-03-13 16:26:38 +0000
@@ -114,12 +114,10 @@
114114
115 # columns have __eq__ implementations that do things we don't want - we115 # columns have __eq__ implementations that do things we don't want - we
116 # want to look these up in a dict and use identity semantics116 # want to look these up in a dict and use identity semantics
117 id_positions = dict((id(column), i)117 id_positions = {id(column): i for i, column in enumerate(self.columns)}
118 for i, column in enumerate(self.columns))
119118
120 self.primary_key_idx = dict((id(column), i)119 self.primary_key_idx = {id(column): i
121 for i, column in120 for i, column in enumerate(self.primary_key)}
122 enumerate(self.primary_key))
123 self.primary_key_pos = tuple(id_positions[id(column)]121 self.primary_key_pos = tuple(id_positions[id(column)]
124 for column in self.primary_key)122 for column in self.primary_key)
125123
@@ -202,7 +200,7 @@
202 from storm.cextensions import ObjectInfo, get_obj_info200 from storm.cextensions import ObjectInfo, get_obj_info
203201
204202
205class ClassAlias(object):203class ClassAlias:
206 """Create a named alias for a Storm class for use in queries.204 """Create a named alias for a Storm class for use in queries.
207205
208 This is useful basically when the SQL 'AS' feature is desired in code using206 This is useful basically when the SQL 'AS' feature is desired in code using
209207
=== modified file 'storm/properties.py'
--- storm/properties.py 2024-03-04 10:59:55 +0000
+++ storm/properties.py 2024-03-13 16:26:38 +0000
@@ -39,7 +39,7 @@
39 "Pickle", "JSON", "List", "PropertyRegistry"]39 "Pickle", "JSON", "List", "PropertyRegistry"]
4040
4141
42class Property(object):42class Property:
43 """A property representing a database column.43 """A property representing a database column.
4444
45 Properties can be set as attributes of classes that have a45 Properties can be set as attributes of classes that have a
@@ -363,7 +363,7 @@
363363
364 def __init__(self, name=None, primary=False, **kwargs):364 def __init__(self, name=None, primary=False, **kwargs):
365 set_map = dict(kwargs.pop("map"))365 set_map = dict(kwargs.pop("map"))
366 get_map = dict((value, key) for key, value in set_map.items())366 get_map = {value: key for key, value in set_map.items()}
367 if "set_map" in kwargs:367 if "set_map" in kwargs:
368 set_map = dict(kwargs.pop("set_map"))368 set_map = dict(kwargs.pop("set_map"))
369369
@@ -372,7 +372,7 @@
372 SimpleProperty.__init__(self, name, primary, **kwargs)372 SimpleProperty.__init__(self, name, primary, **kwargs)
373373
374374
375class PropertyRegistry(object):375class PropertyRegistry:
376 """376 """
377 An object which remembers the Storm properties specified on377 An object which remembers the Storm properties specified on
378 classes, and is able to translate names to these properties.378 classes, and is able to translate names to these properties.
379379
=== modified file 'storm/references.py'
--- storm/references.py 2024-03-04 10:59:55 +0000
+++ storm/references.py 2024-03-13 16:26:38 +0000
@@ -33,7 +33,7 @@
33__all__ = ["Reference", "ReferenceSet", "Proxy"]33__all__ = ["Reference", "ReferenceSet", "Proxy"]
3434
3535
36class LazyAttribute(object):36class LazyAttribute:
37 """37 """
38 This descriptor will call the named attribute builder to38 This descriptor will call the named attribute builder to
39 initialize the given attribute on first access. It avoids39 initialize the given attribute on first access. It avoids
@@ -63,7 +63,7 @@
63PendingReferenceValue = PendingReferenceValue()63PendingReferenceValue = PendingReferenceValue()
6464
6565
66class Reference(object):66class Reference:
67 """Descriptor for one-to-one relationships.67 """Descriptor for one-to-one relationships.
6868
69 This is typically used when the class that it is being defined on69 This is typically used when the class that it is being defined on
@@ -212,7 +212,7 @@
212 __hash__ = object.__hash__212 __hash__ = object.__hash__
213213
214214
215class ReferenceSet(object):215class ReferenceSet:
216 """Descriptor for many-to-one and many-to-many reference sets.216 """Descriptor for many-to-one and many-to-many reference sets.
217217
218 This is typically used when another class has a foreign key onto the218 This is typically used when another class has a foreign key onto the
@@ -335,7 +335,7 @@
335 self._relation2 = None335 self._relation2 = None
336336
337337
338class BoundReferenceSetBase(object):338class BoundReferenceSetBase:
339339
340 def find(self, *args, **kwargs):340 def find(self, *args, **kwargs):
341 store = Store.of(self._local)341 store = Store.of(self._local)
@@ -471,7 +471,7 @@
471 a native property of C{Foo}.471 a native property of C{Foo}.
472 """472 """
473473
474 class RemoteProp(object):474 class RemoteProp:
475 """475 """
476 This descriptor will resolve and set the _remote_prop attribute476 This descriptor will resolve and set the _remote_prop attribute
477 when it's first used. It avoids having a test at every single477 when it's first used. It avoids having a test at every single
@@ -517,7 +517,7 @@
517 return compile(proxy._remote_prop, state)517 return compile(proxy._remote_prop, state)
518518
519519
520class Relation(object):520class Relation:
521521
522 def __init__(self, local_key, remote_key, many, on_remote):522 def __init__(self, local_key, remote_key, many, on_remote):
523 assert type(local_key) is tuple and type(remote_key) is tuple523 assert type(local_key) is tuple and type(remote_key) is tuple
@@ -963,7 +963,7 @@
963 return self._r_to_l.setdefault(local_cls, map).get(remote_column)963 return self._r_to_l.setdefault(local_cls, map).get(remote_column)
964964
965965
966class PropertyResolver(object):966class PropertyResolver:
967 """Transform strings and pure properties (non-columns) into columns."""967 """Transform strings and pure properties (non-columns) into columns."""
968968
969 def __init__(self, reference, used_cls):969 def __init__(self, reference, used_cls):
970970
=== modified file 'storm/schema/patch.py'
--- storm/schema/patch.py 2024-03-04 10:59:55 +0000
+++ storm/schema/patch.py 2024-03-13 16:26:38 +0000
@@ -61,7 +61,7 @@
61 """Raised when a patch failing with a random exception is found."""61 """Raised when a patch failing with a random exception is found."""
6262
6363
64class Patch(object):64class Patch:
65 """Database object representing an applied patch.65 """Database object representing an applied patch.
6666
67 @version: The version of the patch associated with this object.67 @version: The version of the patch associated with this object.
@@ -75,7 +75,7 @@
75 self.version = version75 self.version = version
7676
7777
78class PatchApplier(object):78class PatchApplier:
79 """Apply to a L{Store} the database patches from a given Python package.79 """Apply to a L{Store} the database patches from a given Python package.
8080
81 @param store: The L{Store} to apply the patches to.81 @param store: The L{Store} to apply the patches to.
@@ -189,7 +189,7 @@
189 return applied189 return applied
190190
191191
192class PatchSet(object):192class PatchSet:
193 """A collection of patch modules.193 """A collection of patch modules.
194194
195 Each patch module lives in a regular Python module file, contained in a195 Each patch module lives in a regular Python module file, contained in a
@@ -269,7 +269,7 @@
269 return os.path.dirname(self._package.__file__)269 return os.path.dirname(self._package.__file__)
270270
271271
272class _EmptyPatchModule(object):272class _EmptyPatchModule:
273 """Fake module object with a no-op C{apply} function."""273 """Fake module object with a no-op C{apply} function."""
274274
275 def apply(self, store):275 def apply(self, store):
276276
=== modified file 'storm/schema/schema.py'
--- storm/schema/schema.py 2024-03-04 10:59:55 +0000
+++ storm/schema/schema.py 2024-03-13 16:26:38 +0000
@@ -63,7 +63,7 @@
63 self.unapplied_versions = unapplied_versions63 self.unapplied_versions = unapplied_versions
6464
6565
66class Schema(object):66class Schema:
67 """Create, drop, clean and patch table schemas.67 """Create, drop, clean and patch table schemas.
6868
69 @param creates: A list of C{CREATE TABLE} statements.69 @param creates: A list of C{CREATE TABLE} statements.
@@ -194,7 +194,7 @@
194 return PatchApplier(store, self._patch_set, committer)194 return PatchApplier(store, self._patch_set, committer)
195195
196196
197class _NoopCommitter(object):197class _NoopCommitter:
198 """Dummy committer that does nothing."""198 """Dummy committer that does nothing."""
199199
200 def commit(self):200 def commit(self):
201201
=== modified file 'storm/schema/sharding.py'
--- storm/schema/sharding.py 2024-03-04 10:59:55 +0000
+++ storm/schema/sharding.py 2024-03-13 16:26:38 +0000
@@ -48,7 +48,7 @@
48 """Raised when stores don't have all the same patch level."""48 """Raised when stores don't have all the same patch level."""
4949
5050
51class Sharding(object):51class Sharding:
52 """Manage L{Shema}s over a collection of L{Store}s."""52 """Manage L{Shema}s over a collection of L{Store}s."""
5353
54 def __init__(self):54 def __init__(self):
5555
=== modified file 'storm/sqlobject.py'
--- storm/sqlobject.py 2024-03-04 10:59:55 +0000
+++ storm/sqlobject.py 2024-03-13 16:26:38 +0000
@@ -61,7 +61,7 @@
61 pass61 pass
6262
6363
64class SQLObjectStyle(object):64class SQLObjectStyle:
6565
66 longID = False66 longID = False
6767
@@ -212,7 +212,7 @@
212 attr_to_prop[id_name] = "id"212 attr_to_prop[id_name] = "id"
213213
214 # Notice that obj is the class since this is the metaclass.214 # Notice that obj is the class since this is the metaclass.
215 obj = super(SQLObjectMeta, cls).__new__(cls, name, bases, dict)215 obj = super().__new__(cls, name, bases, dict)
216216
217 property_registry = obj._storm_property_registry217 property_registry = obj._storm_property_registry
218218
@@ -239,14 +239,14 @@
239 return obj239 return obj
240240
241241
242class DotQ(object):242class DotQ:
243 """A descriptor that mimics the SQLObject 'Table.q' syntax"""243 """A descriptor that mimics the SQLObject 'Table.q' syntax"""
244244
245 def __get__(self, obj, cls=None):245 def __get__(self, obj, cls=None):
246 return BoundDotQ(cls)246 return BoundDotQ(cls)
247247
248248
249class BoundDotQ(object):249class BoundDotQ:
250250
251 def __init__(self, cls):251 def __init__(self, cls):
252 self._cls = cls252 self._cls = cls
@@ -374,7 +374,7 @@
374 store.autoreload(self)374 store.autoreload(self)
375375
376376
377class SQLObjectResultSet(object):377class SQLObjectResultSet:
378 """SQLObject-equivalent of the ResultSet class in Storm.378 """SQLObject-equivalent of the ResultSet class in Storm.
379379
380 Storm handles joins in the Store interface, while SQLObject380 Storm handles joins in the Store interface, while SQLObject
@@ -638,7 +638,7 @@
638638
639639
640640
641class PropertyAdapter(object):641class PropertyAdapter:
642642
643 _kwargs = {}643 _kwargs = {}
644644
@@ -668,11 +668,11 @@
668 default = Undef668 default = Undef
669 else:669 else:
670 default_factory = Undef670 default_factory = Undef
671 super(PropertyAdapter, self).__init__(dbName, allow_none=not notNull,671 super().__init__(dbName, allow_none=not notNull,
672 default_factory=default_factory,672 default_factory=default_factory,
673 default=default,673 default=default,
674 validator=storm_validator,674 validator=storm_validator,
675 **self._kwargs)675 **self._kwargs)
676676
677677
678# DEPRECATED: On Python 2, this used to be a more relaxed version of678# DEPRECATED: On Python 2, this used to be a more relaxed version of
@@ -708,7 +708,7 @@
708 pass708 pass
709709
710710
711class ForeignKey(object):711class ForeignKey:
712712
713 def __init__(self, foreignKey, **kwargs):713 def __init__(self, foreignKey, **kwargs):
714 self.foreignKey = foreignKey714 self.foreignKey = foreignKey
@@ -753,7 +753,7 @@
753class SingleJoin(Reference):753class SingleJoin(Reference):
754754
755 def __init__(self, otherClass, joinColumn, prejoins=_IGNORED):755 def __init__(self, otherClass, joinColumn, prejoins=_IGNORED):
756 super(SingleJoin, self).__init__(756 super().__init__(
757 "<primary key>", "%s.%s" % (otherClass, joinColumn),757 "<primary key>", "%s.%s" % (otherClass, joinColumn),
758 on_remote=True)758 on_remote=True)
759759
760760
=== modified file 'storm/store.py'
--- storm/store.py 2024-03-04 10:59:55 +0000
+++ storm/store.py 2024-03-13 16:26:38 +0000
@@ -55,7 +55,7 @@
55PENDING_REMOVE = 255PENDING_REMOVE = 2
5656
5757
58class Store(object):58class Store:
59 """The Storm Store.59 """The Storm Store.
6060
61 This is the highest-level interface to a database. It manages61 This is the highest-level interface to a database. It manages
@@ -479,7 +479,7 @@
479 if n > 0:479 if n > 0:
480 before_set = predecessors.get(after_info)480 before_set = predecessors.get(after_info)
481 if before_set is None:481 if before_set is None:
482 predecessors[after_info] = set((before_info,))482 predecessors[after_info] = {before_info}
483 else:483 else:
484 before_set.add(before_info)484 before_set.add(before_info)
485485
@@ -918,7 +918,7 @@
918 result, result.get_one())918 result, result.get_one())
919919
920920
921class ResultSet(object):921class ResultSet:
922 """The representation of the results of a query.922 """The representation of the results of a query.
923923
924 Note that having an instance of this class does not indicate that924 Note that having an instance of this class does not indicate that
@@ -1518,7 +1518,7 @@
1518 return self._set_expr(Intersect, other, all)1518 return self._set_expr(Intersect, other, all)
15191519
15201520
1521class EmptyResultSet(object):1521class EmptyResultSet:
1522 """An object that looks like a L{ResultSet} but represents no rows.1522 """An object that looks like a L{ResultSet} but represents no rows.
15231523
1524 This is convenient for application developers who want to provide1524 This is convenient for application developers who want to provide
@@ -1645,7 +1645,7 @@
1645 return self1645 return self
16461646
16471647
1648class TableSet(object):1648class TableSet:
1649 """The representation of a set of tables which can be queried at once.1649 """The representation of a set of tables which can be queried at once.
16501650
1651 This will typically be constructed by a call to L{Store.using}.1651 This will typically be constructed by a call to L{Store.using}.
@@ -1675,7 +1675,7 @@
1675Store._table_set = TableSet1675Store._table_set = TableSet
16761676
16771677
1678class FindSpec(object):1678class FindSpec:
1679 """The set of tables or expressions in the result of L{Store.find}."""1679 """The set of tables or expressions in the result of L{Store.find}."""
16801680
1681 def __init__(self, cls_spec):1681 def __init__(self, cls_spec):
@@ -1859,7 +1859,7 @@
1859AutoReload = AutoReload()1859AutoReload = AutoReload()
18601860
18611861
1862class block_access(object):1862class block_access:
1863 """1863 """
1864 Context manager blocks database access by one or more L{Store}\\ s in the1864 Context manager blocks database access by one or more L{Store}\\ s in the
1865 managed scope.1865 managed scope.
18661866
=== modified file 'storm/testing.py'
--- storm/testing.py 2024-03-04 10:59:55 +0000
+++ storm/testing.py 2024-03-13 16:26:38 +0000
@@ -16,7 +16,7 @@
16 """16 """
1717
18 def __init__(self):18 def __init__(self):
19 super(CaptureTracer, self).__init__()19 super().__init__()
20 self.queries = []20 self.queries = []
2121
22 def _setUp(self):22 def _setUp(self):
2323
=== modified file 'storm/tests/cache.py'
--- storm/tests/cache.py 2024-03-04 10:59:55 +0000
+++ storm/tests/cache.py 2024-03-13 16:26:38 +0000
@@ -6,7 +6,7 @@
6from storm.tests.helper import TestHelper6from storm.tests.helper import TestHelper
77
88
9class StubObjectInfo(object):9class StubObjectInfo:
1010
11 def __init__(self, id):11 def __init__(self, id):
12 self.id = id12 self.id = id
@@ -26,7 +26,7 @@
26 return self.id < other.id26 return self.id < other.id
2727
2828
29class StubClass(object):29class StubClass:
3030
31 __storm_table__ = "stub_class"31 __storm_table__ = "stub_class"
3232
@@ -38,7 +38,7 @@
38 Cache = Cache38 Cache = Cache
3939
40 def setUp(self):40 def setUp(self):
41 super(BaseCacheTest, self).setUp()41 super().setUp()
42 self.obj_infos = [StubObjectInfo(i) for i in range(10)]42 self.obj_infos = [StubObjectInfo(i) for i in range(10)]
43 for i in range(len(self.obj_infos)):43 for i in range(len(self.obj_infos)):
44 setattr(self, "obj%d" % (i+1), self.obj_infos[i])44 setattr(self, "obj%d" % (i+1), self.obj_infos[i])
@@ -194,7 +194,7 @@
194 Cache = GenerationalCache194 Cache = GenerationalCache
195195
196 def setUp(self):196 def setUp(self):
197 super(TestGenerationalCache, self).setUp()197 super().setUp()
198 self.obj1 = StubObjectInfo(1)198 self.obj1 = StubObjectInfo(1)
199 self.obj2 = StubObjectInfo(2)199 self.obj2 = StubObjectInfo(2)
200 self.obj3 = StubObjectInfo(3)200 self.obj3 = StubObjectInfo(3)
201201
=== modified file 'storm/tests/database.py'
--- storm/tests/database.py 2024-03-04 10:59:55 +0000
+++ storm/tests/database.py 2024-03-13 16:26:38 +0000
@@ -36,7 +36,7 @@
36marker = object()36marker = object()
3737
3838
39class RawConnection(object):39class RawConnection:
4040
41 closed = False41 closed = False
4242
@@ -56,7 +56,7 @@
56 self.executed.append("CCLOSE")56 self.executed.append("CCLOSE")
5757
5858
59class RawCursor(object):59class RawCursor:
6060
61 def __init__(self, arraysize=1, executed=None):61 def __init__(self, arraysize=1, executed=None):
62 self.arraysize = arraysize62 self.arraysize = arraysize
@@ -91,7 +91,7 @@
91 return result91 return result
9292
9393
94class FakeConnection(object):94class FakeConnection:
9595
96 def __init__(self):96 def __init__(self):
97 self._database = Database()97 self._database = Database()
@@ -100,7 +100,7 @@
100 return _function(*args, **kwargs)100 return _function(*args, **kwargs)
101101
102102
103class FakeTracer(object):103class FakeTracer:
104104
105 def __init__(self, stream=None):105 def __init__(self, stream=None):
106 self.seen = []106 self.seen = []
@@ -538,7 +538,7 @@
538 self.assertEqual(self.uri.database, "db")538 self.assertEqual(self.uri.database, "db")
539539
540 def test_create_database_with_unicode(self):540 def test_create_database_with_unicode(self):
541 create_database(u"db_module:db")541 create_database("db_module:db")
542 self.assertTrue(self.uri)542 self.assertTrue(self.uri)
543 self.assertEqual(self.uri.scheme, "db_module")543 self.assertEqual(self.uri.scheme, "db_module")
544 self.assertEqual(self.uri.database, "db")544 self.assertEqual(self.uri.database, "db")
545545
=== modified file 'storm/tests/databases/base.py'
--- storm/tests/databases/base.py 2024-03-04 10:59:55 +0000
+++ storm/tests/databases/base.py 2024-03-13 16:26:38 +0000
@@ -1,5 +1,3 @@
1
2# -*- encoding: utf-8 -*-
3#1#
4# Copyright (c) 2006, 2007 Canonical2# Copyright (c) 2006, 2007 Canonical
5#3#
@@ -41,18 +39,18 @@
41from storm.tests.helper import MakePath39from storm.tests.helper import MakePath
4240
4341
44class Marker(object):42class Marker:
45 pass43 pass
4644
47marker = Marker()45marker = Marker()
4846
4947
50class DatabaseTest(object):48class DatabaseTest:
5149
52 supports_microseconds = True50 supports_microseconds = True
5351
54 def setUp(self):52 def setUp(self):
55 super(DatabaseTest, self).setUp()53 super().setUp()
56 self.create_database()54 self.create_database()
57 self.create_connection()55 self.create_connection()
58 self.drop_tables()56 self.drop_tables()
@@ -64,7 +62,7 @@
64 self.drop_tables()62 self.drop_tables()
65 self.drop_connection()63 self.drop_connection()
66 self.drop_database()64 self.drop_database()
67 super(DatabaseTest, self).tearDown()65 super().tearDown()
6866
69 def create_database(self):67 def create_database(self):
70 raise NotImplementedError68 raise NotImplementedError
@@ -144,7 +142,7 @@
144 self.assertTrue(result.get_one())142 self.assertTrue(result.get_one())
145143
146 def test_execute_unicode_result(self):144 def test_execute_unicode_result(self):
147 result = self.connection.execute(u"SELECT title FROM test")145 result = self.connection.execute("SELECT title FROM test")
148 self.assertTrue(isinstance(result, Result))146 self.assertTrue(isinstance(result, Result))
149 row = result.get_one()147 row = result.get_one()
150 self.assertEqual(row, ("Title 10",))148 self.assertEqual(row, ("Title 10",))
@@ -213,7 +211,7 @@
213 "VALUES ('Title 30')")211 "VALUES ('Title 30')")
214 primary_key = (Column("id", SQLToken("test")),212 primary_key = (Column("id", SQLToken("test")),
215 Column("title", SQLToken("test")))213 Column("title", SQLToken("test")))
216 primary_variables = (Variable(), Variable(u"Title 30"))214 primary_variables = (Variable(), Variable("Title 30"))
217 expr = result.get_insert_identity(primary_key, primary_variables)215 expr = result.get_insert_identity(primary_key, primary_variables)
218 select = Select(Column("title", SQLToken("test")), expr)216 select = Select(Column("title", SQLToken("test")), expr)
219 result = self.connection.execute(select)217 result = self.connection.execute(select)
@@ -408,7 +406,7 @@
408 self.connection.execute("INSERT INTO test VALUES (40, '!!blah')")406 self.connection.execute("INSERT INTO test VALUES (40, '!!blah')")
409 id = Column("id", SQLToken("test"))407 id = Column("id", SQLToken("test"))
410 title = Column("title", SQLToken("test"))408 title = Column("title", SQLToken("test"))
411 expr = Select(id, title.startswith(u"!!_%"))409 expr = Select(id, title.startswith("!!_%"))
412 result = list(self.connection.execute(expr))410 result = list(self.connection.execute(expr))
413 self.assertEqual(result, [(30,)])411 self.assertEqual(result, [(30,)])
414412
@@ -417,7 +415,7 @@
417 self.connection.execute("INSERT INTO test VALUES (40, 'blah!!')")415 self.connection.execute("INSERT INTO test VALUES (40, 'blah!!')")
418 id = Column("id", SQLToken("test"))416 id = Column("id", SQLToken("test"))
419 title = Column("title", SQLToken("test"))417 title = Column("title", SQLToken("test"))
420 expr = Select(id, title.endswith(u"_%!!"))418 expr = Select(id, title.endswith("_%!!"))
421 result = list(self.connection.execute(expr))419 result = list(self.connection.execute(expr))
422 self.assertEqual(result, [(30,)])420 self.assertEqual(result, [(30,)])
423421
@@ -426,7 +424,7 @@
426 self.connection.execute("INSERT INTO test VALUES (40, 'blah!!x')")424 self.connection.execute("INSERT INTO test VALUES (40, 'blah!!x')")
427 id = Column("id", SQLToken("test"))425 id = Column("id", SQLToken("test"))
428 title = Column("title", SQLToken("test"))426 title = Column("title", SQLToken("test"))
429 expr = Select(id, title.contains_string(u"_%!!"))427 expr = Select(id, title.contains_string("_%!!"))
430 result = list(self.connection.execute(expr))428 result = list(self.connection.execute(expr))
431 self.assertEqual(result, [(30,)])429 self.assertEqual(result, [(30,)])
432430
@@ -459,10 +457,10 @@
459 self.assertEqual(('error message',), wrapped.args)457 self.assertEqual(('error message',), wrapped.args)
460458
461459
462class TwoPhaseCommitTest(object):460class TwoPhaseCommitTest:
463461
464 def setUp(self):462 def setUp(self):
465 super(TwoPhaseCommitTest, self).setUp()463 super().setUp()
466 self.create_database()464 self.create_database()
467 self.create_connection()465 self.create_connection()
468 self.drop_tables()466 self.drop_tables()
@@ -471,7 +469,7 @@
471 def tearDown(self):469 def tearDown(self):
472 self.drop_tables()470 self.drop_tables()
473 self.drop_connection()471 self.drop_connection()
474 super(TwoPhaseCommitTest, self).tearDown()472 super().tearDown()
475473
476 def create_database(self):474 def create_database(self):
477 raise NotImplementedError475 raise NotImplementedError
@@ -630,7 +628,7 @@
630 self.assertFalse(result.get_one())628 self.assertFalse(result.get_one())
631629
632630
633class UnsupportedDatabaseTest(object):631class UnsupportedDatabaseTest:
634632
635 helpers = [MakePath]633 helpers = [MakePath]
636634
@@ -686,14 +684,14 @@
686 sys.modules.update(dbapi_modules)684 sys.modules.update(dbapi_modules)
687685
688686
689class DatabaseDisconnectionMixin(object):687class DatabaseDisconnectionMixin:
690688
691 environment_variable = ""689 environment_variable = ""
692 host_environment_variable = ""690 host_environment_variable = ""
693 default_port = None691 default_port = None
694692
695 def setUp(self):693 def setUp(self):
696 super(DatabaseDisconnectionMixin, self).setUp()694 super().setUp()
697 self.create_database_and_proxy()695 self.create_database_and_proxy()
698 self.create_connection()696 self.create_connection()
699697
@@ -701,7 +699,7 @@
701 self.drop_connection()699 self.drop_connection()
702 self.drop_database()700 self.drop_database()
703 self.proxy.close()701 self.proxy.close()
704 super(DatabaseDisconnectionMixin, self).tearDown()702 super().tearDown()
705703
706 def is_supported(self):704 def is_supported(self):
707 return bool(self.get_uri())705 return bool(self.get_uri())
@@ -884,7 +882,7 @@
884 self.connection.close()882 self.connection.close()
885883
886884
887class TwoPhaseCommitDisconnectionTest(object):885class TwoPhaseCommitDisconnectionTest:
888886
889 def test_begin_after_rollback_with_disconnection_error(self):887 def test_begin_after_rollback_with_disconnection_error(self):
890 """888 """
891889
=== modified file 'storm/tests/databases/mysql.py'
--- storm/tests/databases/mysql.py 2024-03-04 10:59:55 +0000
+++ storm/tests/databases/mysql.py 2024-03-13 16:26:38 +0000
@@ -99,7 +99,7 @@
99 id_column = Column("id", "test")99 id_column = Column("id", "test")
100 id_variable = IntVariable()100 id_variable = IntVariable()
101 title_column = Column("title", "test")101 title_column = Column("title", "test")
102 title_variable = UnicodeVariable(u"testing")102 title_variable = UnicodeVariable("testing")
103103
104 # This is not part of the table. It is just used to show that104 # This is not part of the table. It is just used to show that
105 # only one primary key variable is set from the insert ID.105 # only one primary key variable is set from the insert ID.
@@ -161,4 +161,4 @@
161 if "unix_socket" in uri.options:161 if "unix_socket" in uri.options:
162 return create_proxy_and_uri(uri)[0]162 return create_proxy_and_uri(uri)[0]
163 else:163 else:
164 return super(MySQLDisconnectionTest, self).create_proxy(uri)164 return super().create_proxy(uri)
165165
=== modified file 'storm/tests/databases/postgres.py'
--- storm/tests/databases/postgres.py 2024-03-04 10:59:55 +0000
+++ storm/tests/databases/postgres.py 2024-03-13 16:26:38 +0000
@@ -116,7 +116,7 @@
116 " json JSON)")116 " json JSON)")
117117
118 def drop_tables(self):118 def drop_tables(self):
119 super(PostgresTest, self).drop_tables()119 super().drop_tables()
120 tables = ("like_case_insensitive_test", "returning_test", "json_test")120 tables = ("like_case_insensitive_test", "returning_test", "json_test")
121 for table in tables:121 for table in tables:
122 try:122 try:
@@ -126,7 +126,7 @@
126 self.connection.rollback()126 self.connection.rollback()
127127
128 def create_sample_data(self):128 def create_sample_data(self):
129 super(PostgresTest, self).create_sample_data()129 super().create_sample_data()
130 self.connection.execute("INSERT INTO like_case_insensitive_test "130 self.connection.execute("INSERT INTO like_case_insensitive_test "
131 "(description) VALUES ('hullah')")131 "(description) VALUES ('hullah')")
132 self.connection.execute("INSERT INTO like_case_insensitive_test "132 self.connection.execute("INSERT INTO like_case_insensitive_test "
@@ -318,35 +318,35 @@
318318
319 def test_case_default_like(self):319 def test_case_default_like(self):
320320
321 like = Like(SQLRaw("description"), u"%hullah%")321 like = Like(SQLRaw("description"), "%hullah%")
322 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])322 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])
323 result = self.connection.execute(expr)323 result = self.connection.execute(expr)
324 self.assertEqual(result.get_all(), [(1,)])324 self.assertEqual(result.get_all(), [(1,)])
325325
326 like = Like(SQLRaw("description"), u"%HULLAH%")326 like = Like(SQLRaw("description"), "%HULLAH%")
327 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])327 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])
328 result = self.connection.execute(expr)328 result = self.connection.execute(expr)
329 self.assertEqual(result.get_all(), [(2,)])329 self.assertEqual(result.get_all(), [(2,)])
330330
331 def test_case_sensitive_like(self):331 def test_case_sensitive_like(self):
332332
333 like = Like(SQLRaw("description"), u"%hullah%", case_sensitive=True)333 like = Like(SQLRaw("description"), "%hullah%", case_sensitive=True)
334 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])334 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])
335 result = self.connection.execute(expr)335 result = self.connection.execute(expr)
336 self.assertEqual(result.get_all(), [(1,)])336 self.assertEqual(result.get_all(), [(1,)])
337337
338 like = Like(SQLRaw("description"), u"%HULLAH%", case_sensitive=True)338 like = Like(SQLRaw("description"), "%HULLAH%", case_sensitive=True)
339 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])339 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])
340 result = self.connection.execute(expr)340 result = self.connection.execute(expr)
341 self.assertEqual(result.get_all(), [(2,)])341 self.assertEqual(result.get_all(), [(2,)])
342342
343 def test_case_insensitive_like(self):343 def test_case_insensitive_like(self):
344344
345 like = Like(SQLRaw("description"), u"%hullah%", case_sensitive=False)345 like = Like(SQLRaw("description"), "%hullah%", case_sensitive=False)
346 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])346 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])
347 result = self.connection.execute(expr)347 result = self.connection.execute(expr)
348 self.assertEqual(result.get_all(), [(1,), (2,)])348 self.assertEqual(result.get_all(), [(1,), (2,)])
349 like = Like(SQLRaw("description"), u"%HULLAH%", case_sensitive=False)349 like = Like(SQLRaw("description"), "%HULLAH%", case_sensitive=False)
350 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])350 expr = Select(SQLRaw("id"), like, tables=["like_case_insensitive_test"])
351 result = self.connection.execute(expr)351 result = self.connection.execute(expr)
352 self.assertEqual(result.get_all(), [(1,), (2,)])352 self.assertEqual(result.get_all(), [(1,), (2,)])
@@ -361,7 +361,7 @@
361 self.assertEqual(result.get_one(), (None,))361 self.assertEqual(result.get_one(), (None,))
362362
363 def test_compile_table_with_schema(self):363 def test_compile_table_with_schema(self):
364 class Foo(object):364 class Foo:
365 __storm_table__ = "my schema.my table"365 __storm_table__ = "my schema.my table"
366 id = Int("my.column", primary=True)366 id = Int("my.column", primary=True)
367 self.assertEqual(compile(Select(Foo.id)),367 self.assertEqual(compile(Select(Foo.id)),
@@ -371,7 +371,7 @@
371 def test_compile_case(self):371 def test_compile_case(self):
372 """The Case expr is compiled in a Postgres' CASE expression."""372 """The Case expr is compiled in a Postgres' CASE expression."""
373 cases = [373 cases = [
374 (Column("foo") > 3, u"big"), (Column("bar") == None, 4)]374 (Column("foo") > 3, "big"), (Column("bar") == None, 4)]
375 state = State()375 state = State()
376 statement = compile(Case(cases), state)376 statement = compile(Case(cases), state)
377 self.assertEqual(377 self.assertEqual(
@@ -385,7 +385,7 @@
385 If a default is provided, the resulting CASE expression includes385 If a default is provided, the resulting CASE expression includes
386 an ELSE clause.386 an ELSE clause.
387 """387 """
388 cases = [(Column("foo") > 3, u"big")]388 cases = [(Column("foo") > 3, "big")]
389 state = State()389 state = State()
390 statement = compile(Case(cases, default=9), state)390 statement = compile(Case(cases, default=9), state)
391 self.assertEqual(391 self.assertEqual(
@@ -398,7 +398,7 @@
398 If an expression is provided, the resulting CASE expression uses the398 If an expression is provided, the resulting CASE expression uses the
399 simple syntax.399 simple syntax.
400 """400 """
401 cases = [(1, u"one"), (2, u"two")]401 cases = [(1, "one"), (2, "two")]
402 state = State()402 state = State()
403 statement = compile(Case(cases, expression=Column("foo")), state)403 statement = compile(Case(cases, expression=Column("foo")), state)
404 self.assertEqual(404 self.assertEqual(
@@ -554,7 +554,7 @@
554554
555 result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL")555 result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL")
556 # It matches read committed in Postgres internel556 # It matches read committed in Postgres internel
557 self.assertEqual(result.get_one()[0], u"read committed")557 self.assertEqual(result.get_one()[0], "read committed")
558558
559 connection.execute("INSERT INTO bin_test VALUES (1, 'foo')")559 connection.execute("INSERT INTO bin_test VALUES (1, 'foo')")
560560
@@ -571,7 +571,7 @@
571 self.addCleanup(connection.close)571 self.addCleanup(connection.close)
572572
573 result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL")573 result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL")
574 self.assertEqual(result.get_one()[0], u"read committed")574 self.assertEqual(result.get_one()[0], "read committed")
575575
576 connection.execute("INSERT INTO bin_test VALUES (1, 'foo')")576 connection.execute("INSERT INTO bin_test VALUES (1, 'foo')")
577577
@@ -600,7 +600,7 @@
600 self.addCleanup(connection.close)600 self.addCleanup(connection.close)
601601
602 result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL")602 result = connection.execute("SHOW TRANSACTION ISOLATION LEVEL")
603 self.assertEqual(result.get_one()[0], u"serializable")603 self.assertEqual(result.get_one()[0], "serializable")
604604
605 # Start a transaction605 # Start a transaction
606 result = connection.execute("SELECT 1")606 result = connection.execute("SELECT 1")
@@ -623,9 +623,9 @@
623 import psycopg2623 import psycopg2
624 psycopg2_version = psycopg2.__version__.split(None, 1)[0]624 psycopg2_version = psycopg2.__version__.split(None, 1)[0]
625 if psycopg2_version < "2.4.2":625 if psycopg2_version < "2.4.2":
626 self.assertEqual(result.get_one()[0], u"serializable")626 self.assertEqual(result.get_one()[0], "serializable")
627 else:627 else:
628 self.assertEqual(result.get_one()[0], u"repeatable read")628 self.assertEqual(result.get_one()[0], "repeatable read")
629629
630 def test_unknown_serialization(self):630 def test_unknown_serialization(self):
631 self.assertRaises(ValueError, create_database,631 self.assertRaises(ValueError, create_database,
@@ -661,8 +661,8 @@
661 def test_json_element(self):661 def test_json_element(self):
662 "JSONElement returns an element from a json field."662 "JSONElement returns an element from a json field."
663 connection = self.database.connect()663 connection = self.database.connect()
664 json_value = Cast(u'{"a": 1}', "json")664 json_value = Cast('{"a": 1}', "json")
665 expr = JSONElement(json_value, u"a")665 expr = JSONElement(json_value, "a")
666 # Need to cast as text since newer psycopg versions decode JSON666 # Need to cast as text since newer psycopg versions decode JSON
667 # automatically.667 # automatically.
668 result = connection.execute(Select(Cast(expr, "text")))668 result = connection.execute(Select(Cast(expr, "text")))
@@ -673,8 +673,8 @@
673 def test_json_text_element(self):673 def test_json_text_element(self):
674 "JSONTextElement returns an element from a json field as text."674 "JSONTextElement returns an element from a json field as text."
675 connection = self.database.connect()675 connection = self.database.connect()
676 json_value = Cast(u'{"a": 1}', "json")676 json_value = Cast('{"a": 1}', "json")
677 expr = JSONTextElement(json_value, u"a")677 expr = JSONTextElement(json_value, "a")
678 result = connection.execute(Select(expr))678 result = connection.execute(Select(expr))
679 self.assertEqual("1", result.get_one()[0])679 self.assertEqual("1", result.get_one()[0])
680 result = connection.execute(Select(Func("pg_typeof", expr)))680 result = connection.execute(Select(Func("pg_typeof", expr)))
@@ -683,7 +683,7 @@
683 def test_json_property(self):683 def test_json_property(self):
684 """The JSON property is encoded as JSON"""684 """The JSON property is encoded as JSON"""
685685
686 class TestModel(object):686 class TestModel:
687 __storm_table__ = "json_test"687 __storm_table__ = "json_test"
688688
689 id = Int(primary=True)689 id = Int(primary=True)
@@ -747,7 +747,7 @@
747 if uri.host.startswith("/"):747 if uri.host.startswith("/"):
748 return create_proxy_and_uri(uri)[0]748 return create_proxy_and_uri(uri)[0]
749 else:749 else:
750 return super(PostgresDisconnectionTest, self).create_proxy(uri)750 return super().create_proxy(uri)
751751
752 def test_rollback_swallows_InterfaceError(self):752 def test_rollback_swallows_InterfaceError(self):
753 """Test that InterfaceErrors get caught on rollback().753 """Test that InterfaceErrors get caught on rollback().
@@ -765,18 +765,17 @@
765 self.fail('Exception should have been swallowed: %s' % repr(exc))765 self.fail('Exception should have been swallowed: %s' % repr(exc))
766766
767767
768class PostgresDisconnectionTestWithoutProxyBase(object):768class PostgresDisconnectionTestWithoutProxyBase:
769 # DatabaseDisconnectionTest uses a socket proxy to simulate broken769 # DatabaseDisconnectionTest uses a socket proxy to simulate broken
770 # connections. This class tests some other causes of disconnection.770 # connections. This class tests some other causes of disconnection.
771771
772 database_uri = None772 database_uri = None
773773
774 def is_supported(self):774 def is_supported(self):
775 return bool(self.database_uri) and super(775 return bool(self.database_uri) and super().is_supported()
776 PostgresDisconnectionTestWithoutProxyBase, self).is_supported()
777776
778 def setUp(self):777 def setUp(self):
779 super(PostgresDisconnectionTestWithoutProxyBase, self).setUp()778 super().setUp()
780 self.database = create_database(self.database_uri)779 self.database = create_database(self.database_uri)
781780
782 def test_terminated_backend(self):781 def test_terminated_backend(self):
@@ -816,14 +815,14 @@
816 database_uri = os.environ.get("STORM_POSTGRES_HOST_URI")815 database_uri = os.environ.get("STORM_POSTGRES_HOST_URI")
817816
818 def setUp(self):817 def setUp(self):
819 super(PostgresDisconnectionTestWithoutProxyTCPSockets, self).setUp()818 super().setUp()
820 if self.database.get_uri().host.startswith("/"):819 if self.database.get_uri().host.startswith("/"):
821 proxy, proxy_uri = create_proxy_and_uri(self.database.get_uri())820 proxy, proxy_uri = create_proxy_and_uri(self.database.get_uri())
822 self.addCleanup(proxy.close)821 self.addCleanup(proxy.close)
823 self.database = create_database(proxy_uri)822 self.database = create_database(proxy_uri)
824823
825824
826class PostgresDisconnectionTestWithPGBouncerBase(object):825class PostgresDisconnectionTestWithPGBouncerBase:
827 # Connecting via pgbouncer <http://pgfoundry.org/projects/pgbouncer>826 # Connecting via pgbouncer <http://pgfoundry.org/projects/pgbouncer>
828 # introduces new possible causes of disconnections.827 # introduces new possible causes of disconnections.
829828
@@ -833,7 +832,7 @@
833 bool(os.environ.get("STORM_POSTGRES_HOST_URI")))832 bool(os.environ.get("STORM_POSTGRES_HOST_URI")))
834833
835 def setUp(self):834 def setUp(self):
836 super(PostgresDisconnectionTestWithPGBouncerBase, self).setUp()835 super().setUp()
837 database_uri = URI(os.environ["STORM_POSTGRES_HOST_URI"])836 database_uri = URI(os.environ["STORM_POSTGRES_HOST_URI"])
838 if database_uri.host.startswith("/"):837 if database_uri.host.startswith("/"):
839 proxy, database_uri = create_proxy_and_uri(database_uri)838 proxy, database_uri = create_proxy_and_uri(database_uri)
@@ -889,7 +888,7 @@
889 return bool(os.environ.get("STORM_POSTGRES_URI"))888 return bool(os.environ.get("STORM_POSTGRES_URI"))
890889
891 def setUp(self):890 def setUp(self):
892 super(PostgresTimeoutTracerTest, self).setUp()891 super().setUp()
893 self.database = create_database(os.environ["STORM_POSTGRES_URI"])892 self.database = create_database(os.environ["STORM_POSTGRES_URI"])
894 self.connection = self.database.connect()893 self.connection = self.database.connect()
895 install_tracer(self.tracer)894 install_tracer(self.tracer)
@@ -898,7 +897,7 @@
898897
899 def tearDown(self):898 def tearDown(self):
900 self.connection.close()899 self.connection.close()
901 super(PostgresTimeoutTracerTest, self).tearDown()900 super().tearDown()
902901
903 def test_set_statement_timeout(self):902 def test_set_statement_timeout(self):
904 result = self.connection.execute("SHOW statement_timeout")903 result = self.connection.execute("SHOW statement_timeout")
905904
=== modified file 'storm/tests/databases/proxy.py'
--- storm/tests/databases/proxy.py 2024-03-04 10:59:55 +0000
+++ storm/tests/databases/proxy.py 2024-03-13 16:26:38 +0000
@@ -1,4 +1,3 @@
1# -*- encoding: utf-8 -*-
2#1#
3# Copyright (c) 2006, 2007 Canonical2# Copyright (c) 2006, 2007 Canonical
4#3#
@@ -59,7 +58,7 @@
59 chunk = os.read(self.request.fileno(), 1024)58 chunk = os.read(self.request.fileno(), 1024)
60 try:59 try:
61 dst.send(chunk)60 dst.send(chunk)
62 except socket.error as e:61 except OSError as e:
63 if e.errno == errno.EPIPE:62 if e.errno == errno.EPIPE:
64 return63 return
65 raise64 raise
6665
=== modified file 'storm/tests/databases/sqlite.py'
--- storm/tests/databases/sqlite.py 2024-03-04 10:59:55 +0000
+++ storm/tests/databases/sqlite.py 2024-03-13 16:26:38 +0000
@@ -184,9 +184,9 @@
184 [(1,), (2,)])184 [(1,), (2,)])
185185
186 def test_journal(self):186 def test_journal(self):
187 journal_values = {"DELETE": u'delete', "TRUNCATE": u'truncate',187 journal_values = {"DELETE": 'delete', "TRUNCATE": 'truncate',
188 "PERSIST": u'persist', "MEMORY": u'memory',188 "PERSIST": 'persist', "MEMORY": 'memory',
189 "WAL": u'wal', "OFF": u'off'}189 "WAL": 'wal', "OFF": 'off'}
190 for value in journal_values:190 for value in journal_values:
191 database = SQLite(URI("sqlite:%s?journal_mode=%s" %191 database = SQLite(URI("sqlite:%s?journal_mode=%s" %
192 (self.get_path(), value)))192 (self.get_path(), value)))
@@ -196,9 +196,9 @@
196 journal_values[value])196 journal_values[value])
197197
198 def test_journal_persistency_to_rollback(self):198 def test_journal_persistency_to_rollback(self):
199 journal_values = {"DELETE": u'delete', "TRUNCATE": u'truncate',199 journal_values = {"DELETE": 'delete', "TRUNCATE": 'truncate',
200 "PERSIST": u'persist', "MEMORY": u'memory',200 "PERSIST": 'persist', "MEMORY": 'memory',
201 "WAL": u'wal', "OFF": u'off'}201 "WAL": 'wal', "OFF": 'off'}
202 for value in journal_values:202 for value in journal_values:
203 database = SQLite(URI("sqlite:%s?journal_mode=%s" %203 database = SQLite(URI("sqlite:%s?journal_mode=%s" %
204 (self.get_path(), value)))204 (self.get_path(), value)))
205205
=== modified file 'storm/tests/event.py'
--- storm/tests/event.py 2024-03-04 16:31:48 +0000
+++ storm/tests/event.py 2024-03-13 16:26:38 +0000
@@ -22,7 +22,7 @@
22from storm.tests.helper import TestHelper22from storm.tests.helper import TestHelper
2323
2424
25class Marker(object):25class Marker:
26 def __eq__(self, other):26 def __eq__(self, other):
27 return self is other27 return self is other
2828
2929
=== modified file 'storm/tests/expr.py'
--- storm/tests/expr.py 2024-03-04 10:59:55 +0000
+++ storm/tests/expr.py 2024-03-13 16:26:38 +0000
@@ -188,38 +188,38 @@
188 expr = Func1()188 expr = Func1()
189 self.assertRaises(ExprError, expr.startswith, b"not a unicode string")189 self.assertRaises(ExprError, expr.startswith, b"not a unicode string")
190190
191 like_expr = expr.startswith(u"abc!!_%")191 like_expr = expr.startswith("abc!!_%")
192 self.assertTrue(isinstance(like_expr, Like))192 self.assertTrue(isinstance(like_expr, Like))
193 self.assertIs(like_expr.expr1, expr)193 self.assertIs(like_expr.expr1, expr)
194 self.assertEqual(like_expr.expr2, u"abc!!!!!_!%%")194 self.assertEqual(like_expr.expr2, "abc!!!!!_!%%")
195 self.assertEqual(like_expr.escape, u"!")195 self.assertEqual(like_expr.escape, "!")
196196
197 def test_startswith_case(self):197 def test_startswith_case(self):
198 expr = Func1()198 expr = Func1()
199 like_expr = expr.startswith(u"abc!!_%")199 like_expr = expr.startswith("abc!!_%")
200 self.assertIsNone(like_expr.case_sensitive)200 self.assertIsNone(like_expr.case_sensitive)
201 like_expr = expr.startswith(u"abc!!_%", case_sensitive=True)201 like_expr = expr.startswith("abc!!_%", case_sensitive=True)
202 self.assertIs(True, like_expr.case_sensitive)202 self.assertIs(True, like_expr.case_sensitive)
203 like_expr = expr.startswith(u"abc!!_%", case_sensitive=False)203 like_expr = expr.startswith("abc!!_%", case_sensitive=False)
204 self.assertIs(False, like_expr.case_sensitive)204 self.assertIs(False, like_expr.case_sensitive)
205205
206 def test_endswith(self):206 def test_endswith(self):
207 expr = Func1()207 expr = Func1()
208 self.assertRaises(ExprError, expr.startswith, b"not a unicode string")208 self.assertRaises(ExprError, expr.startswith, b"not a unicode string")
209209
210 like_expr = expr.endswith(u"abc!!_%")210 like_expr = expr.endswith("abc!!_%")
211 self.assertTrue(isinstance(like_expr, Like))211 self.assertTrue(isinstance(like_expr, Like))
212 self.assertIs(like_expr.expr1, expr)212 self.assertIs(like_expr.expr1, expr)
213 self.assertEqual(like_expr.expr2, u"%abc!!!!!_!%")213 self.assertEqual(like_expr.expr2, "%abc!!!!!_!%")
214 self.assertEqual(like_expr.escape, u"!")214 self.assertEqual(like_expr.escape, "!")
215215
216 def test_endswith_case(self):216 def test_endswith_case(self):
217 expr = Func1()217 expr = Func1()
218 like_expr = expr.endswith(u"abc!!_%")218 like_expr = expr.endswith("abc!!_%")
219 self.assertIsNone(like_expr.case_sensitive)219 self.assertIsNone(like_expr.case_sensitive)
220 like_expr = expr.endswith(u"abc!!_%", case_sensitive=True)220 like_expr = expr.endswith("abc!!_%", case_sensitive=True)
221 self.assertIs(True, like_expr.case_sensitive)221 self.assertIs(True, like_expr.case_sensitive)
222 like_expr = expr.endswith(u"abc!!_%", case_sensitive=False)222 like_expr = expr.endswith("abc!!_%", case_sensitive=False)
223 self.assertIs(False, like_expr.case_sensitive)223 self.assertIs(False, like_expr.case_sensitive)
224224
225 def test_contains_string(self):225 def test_contains_string(self):
@@ -227,19 +227,19 @@
227 self.assertRaises(227 self.assertRaises(
228 ExprError, expr.contains_string, b"not a unicode string")228 ExprError, expr.contains_string, b"not a unicode string")
229229
230 like_expr = expr.contains_string(u"abc!!_%")230 like_expr = expr.contains_string("abc!!_%")
231 self.assertTrue(isinstance(like_expr, Like))231 self.assertTrue(isinstance(like_expr, Like))
232 self.assertIs(like_expr.expr1, expr)232 self.assertIs(like_expr.expr1, expr)
233 self.assertEqual(like_expr.expr2, u"%abc!!!!!_!%%")233 self.assertEqual(like_expr.expr2, "%abc!!!!!_!%%")
234 self.assertEqual(like_expr.escape, u"!")234 self.assertEqual(like_expr.escape, "!")
235235
236 def test_contains_string_case(self):236 def test_contains_string_case(self):
237 expr = Func1()237 expr = Func1()
238 like_expr = expr.contains_string(u"abc!!_%")238 like_expr = expr.contains_string("abc!!_%")
239 self.assertIsNone(like_expr.case_sensitive)239 self.assertIsNone(like_expr.case_sensitive)
240 like_expr = expr.contains_string(u"abc!!_%", case_sensitive=True)240 like_expr = expr.contains_string("abc!!_%", case_sensitive=True)
241 self.assertIs(True, like_expr.case_sensitive)241 self.assertIs(True, like_expr.case_sensitive)
242 like_expr = expr.contains_string(u"abc!!_%", case_sensitive=False)242 like_expr = expr.contains_string("abc!!_%", case_sensitive=False)
243 self.assertIs(False, like_expr.case_sensitive)243 self.assertIs(False, like_expr.case_sensitive)
244244
245 def test_is(self):245 def test_is(self):
@@ -513,7 +513,7 @@
513 self.assertEqual(statement, "func1(None)")513 self.assertEqual(statement, "func1(None)")
514514
515 def test_customize_inheritance(self):515 def test_customize_inheritance(self):
516 class C(object): pass516 class C: pass
517 compile_parent = Compile()517 compile_parent = Compile()
518 compile_child = compile_parent.create_child()518 compile_child = compile_parent.create_child()
519519
@@ -610,9 +610,9 @@
610610
611 def test_unicode(self):611 def test_unicode(self):
612 state = State()612 state = State()
613 statement = compile(u"str", state)613 statement = compile("str", state)
614 self.assertEqual(statement, "?")614 self.assertEqual(statement, "?")
615 self.assertVariablesEqual(state.parameters, [UnicodeVariable(u"str")])615 self.assertVariablesEqual(state.parameters, [UnicodeVariable("str")])
616616
617 def test_int(self):617 def test_int(self):
618 state = State()618 state = State()
@@ -812,8 +812,8 @@
812 self.assertEqual(state.parameters, [])812 self.assertEqual(state.parameters, [])
813813
814 def test_select_with_unicode(self):814 def test_select_with_unicode(self):
815 expr = Select(column1, u"1 = 2", table1, order_by=u"column1",815 expr = Select(column1, "1 = 2", table1, order_by="column1",
816 group_by=[u"column2"])816 group_by=["column2"])
817 state = State()817 state = State()
818 statement = compile(expr, state)818 statement = compile(expr, state)
819 self.assertEqual(statement, 'SELECT column1 FROM "table 1" '819 self.assertEqual(statement, 'SELECT column1 FROM "table 1" '
@@ -822,8 +822,8 @@
822 self.assertEqual(state.parameters, [])822 self.assertEqual(state.parameters, [])
823823
824 def test_select_having(self):824 def test_select_having(self):
825 expr = Select(column1, tables=table1, order_by=u"column1",825 expr = Select(column1, tables=table1, order_by="column1",
826 group_by=[u"column2"], having=u"1 = 2")826 group_by=["column2"], having="1 = 2")
827 state = State()827 state = State()
828 statement = compile(expr, state)828 statement = compile(expr, state)
829 self.assertEqual(statement, 'SELECT column1 FROM "table 1" '829 self.assertEqual(statement, 'SELECT column1 FROM "table 1" '
@@ -2244,7 +2244,7 @@
2244 self.assertEqual(py_expr, "b'str'")2244 self.assertEqual(py_expr, "b'str'")
22452245
2246 def test_unicode(self):2246 def test_unicode(self):
2247 py_expr = compile_python(u"str")2247 py_expr = compile_python("str")
2248 self.assertEqual(py_expr, "'str'")2248 self.assertEqual(py_expr, "'str'")
22492249
2250 def test_int(self):2250 def test_int(self):
@@ -2483,7 +2483,7 @@
2483 def test_match_bad_repr(self):2483 def test_match_bad_repr(self):
2484 """The get_matcher() works for expressions containing values2484 """The get_matcher() works for expressions containing values
2485 whose repr is not valid Python syntax."""2485 whose repr is not valid Python syntax."""
2486 class BadRepr(object):2486 class BadRepr:
2487 def __repr__(self):2487 def __repr__(self):
2488 return "$Not a valid Python expression$"2488 return "$Not a valid Python expression$"
24892489
24902490
=== modified file 'storm/tests/helper.py'
--- storm/tests/helper.py 2024-03-04 10:59:55 +0000
+++ storm/tests/helper.py 2024-03-13 16:26:38 +0000
@@ -38,7 +38,7 @@
38 return True38 return True
3939
40 def setUp(self):40 def setUp(self):
41 super(TestHelper, self).setUp()41 super().setUp()
42 self._helper_instances = []42 self._helper_instances = []
43 for helper_factory in self.helpers:43 for helper_factory in self.helpers:
44 helper = helper_factory()44 helper = helper_factory()
@@ -48,7 +48,7 @@
48 def tearDown(self):48 def tearDown(self):
49 for helper in reversed(self._helper_instances):49 for helper in reversed(self._helper_instances):
50 helper.tear_down(self)50 helper.tear_down(self)
51 super(TestHelper, self).tearDown()51 super().tearDown()
5252
53 @property53 @property
54 def _testMethod(self):54 def _testMethod(self):
@@ -61,7 +61,7 @@
61 result.startTest(self)61 result.startTest(self)
62 result.addSkip(self, "Test not supported")62 result.addSkip(self, "Test not supported")
63 return63 return
64 super(TestHelper, self).run(result)64 super().run(result)
6565
66 def assertVariablesEqual(self, checked, expected):66 def assertVariablesEqual(self, checked, expected):
67 self.assertEqual(len(checked), len(expected))67 self.assertEqual(len(checked), len(expected))
@@ -70,7 +70,7 @@
70 self.assertEqual(check.get(), expect.get())70 self.assertEqual(check.get(), expect.get())
7171
7272
73class MakePath(object):73class MakePath:
7474
75 def set_up(self, test_case):75 def set_up(self, test_case):
76 self.dirname = tempfile.mkdtemp()76 self.dirname = tempfile.mkdtemp()
@@ -101,7 +101,7 @@
101 return path101 return path
102102
103103
104class LogKeeper(object):104class LogKeeper:
105 """Record logging information.105 """Record logging information.
106106
107 Puts a 'logfile' attribute on your test case, which is a StringIO107 Puts a 'logfile' attribute on your test case, which is a StringIO
108108
=== modified file 'storm/tests/info.py'
--- storm/tests/info.py 2024-03-04 10:59:55 +0000
+++ storm/tests/info.py 2024-03-13 16:26:38 +0000
@@ -29,7 +29,7 @@
29from storm.tests.helper import TestHelper29from storm.tests.helper import TestHelper
3030
3131
32class Wrapper(object):32class Wrapper:
3333
34 def __init__(self, obj):34 def __init__(self, obj):
35 self.obj = obj35 self.obj = obj
@@ -42,7 +42,7 @@
4242
43 def setUp(self):43 def setUp(self):
44 TestHelper.setUp(self)44 TestHelper.setUp(self)
45 class Class(object):45 class Class:
46 __storm_table__ = "table"46 __storm_table__ = "table"
47 prop1 = Property("column1", primary=True)47 prop1 = Property("column1", primary=True)
48 self.Class = Class48 self.Class = Class
@@ -74,7 +74,7 @@
7474
75 def setUp(self):75 def setUp(self):
76 TestHelper.setUp(self)76 TestHelper.setUp(self)
77 class Class(object):77 class Class:
78 __storm_table__ = "table"78 __storm_table__ = "table"
79 prop1 = Property("column1", primary=True)79 prop1 = Property("column1", primary=True)
80 prop2 = Property("column2")80 prop2 = Property("column2")
@@ -82,7 +82,7 @@
82 self.cls_info = get_cls_info(Class)82 self.cls_info = get_cls_info(Class)
8383
84 def test_invalid_class(self):84 def test_invalid_class(self):
85 class Class(object): pass85 class Class: pass
86 self.assertRaises(ClassInfoError, ClassInfo, Class)86 self.assertRaises(ClassInfoError, ClassInfo, Class)
8787
88 def test_cls(self):88 def test_cls(self):
@@ -110,7 +110,7 @@
110 self.assertEqual(len(self.cls_info.primary_key), 1)110 self.assertEqual(len(self.cls_info.primary_key), 1)
111111
112 def test_primary_key_composed(self):112 def test_primary_key_composed(self):
113 class Class(object):113 class Class:
114 __storm_table__ = "table"114 __storm_table__ = "table"
115 prop1 = Property("column1", primary=2)115 prop1 = Property("column1", primary=2)
116 prop2 = Property("column2", primary=1)116 prop2 = Property("column2", primary=1)
@@ -122,7 +122,7 @@
122 self.assertEqual(len(cls_info.primary_key), 2)122 self.assertEqual(len(cls_info.primary_key), 2)
123123
124 def test_primary_key_composed_with_attribute(self):124 def test_primary_key_composed_with_attribute(self):
125 class Class(object):125 class Class:
126 __storm_table__ = "table"126 __storm_table__ = "table"
127 __storm_primary__ = "prop2", "prop1"127 __storm_primary__ = "prop2", "prop1"
128 # Define primary=True to ensure that the attribute128 # Define primary=True to ensure that the attribute
@@ -137,21 +137,21 @@
137 self.assertEqual(len(cls_info.primary_key), 2)137 self.assertEqual(len(cls_info.primary_key), 2)
138138
139 def test_primary_key_composed_duplicated(self):139 def test_primary_key_composed_duplicated(self):
140 class Class(object):140 class Class:
141 __storm_table__ = "table"141 __storm_table__ = "table"
142 prop1 = Property("column1", primary=True)142 prop1 = Property("column1", primary=True)
143 prop2 = Property("column2", primary=True)143 prop2 = Property("column2", primary=True)
144 self.assertRaises(ClassInfoError, ClassInfo, Class)144 self.assertRaises(ClassInfoError, ClassInfo, Class)
145145
146 def test_primary_key_missing(self):146 def test_primary_key_missing(self):
147 class Class(object):147 class Class:
148 __storm_table__ = "table"148 __storm_table__ = "table"
149 prop1 = Property("column1")149 prop1 = Property("column1")
150 prop2 = Property("column2")150 prop2 = Property("column2")
151 self.assertRaises(ClassInfoError, ClassInfo, Class)151 self.assertRaises(ClassInfoError, ClassInfo, Class)
152152
153 def test_primary_key_attribute_missing(self):153 def test_primary_key_attribute_missing(self):
154 class Class(object):154 class Class:
155 __storm_table__ = "table"155 __storm_table__ = "table"
156 __storm_primary__ = ()156 __storm_primary__ = ()
157 prop1 = Property("column1", primary=True)157 prop1 = Property("column1", primary=True)
@@ -159,7 +159,7 @@
159 self.assertRaises(ClassInfoError, ClassInfo, Class)159 self.assertRaises(ClassInfoError, ClassInfo, Class)
160160
161 def test_primary_key_pos(self):161 def test_primary_key_pos(self):
162 class Class(object):162 class Class:
163 __storm_table__ = "table"163 __storm_table__ = "table"
164 prop1 = Property("column1", primary=2)164 prop1 = Property("column1", primary=2)
165 prop2 = Property("column2")165 prop2 = Property("column2")
@@ -172,7 +172,7 @@
172172
173 def setUp(self):173 def setUp(self):
174 TestHelper.setUp(self)174 TestHelper.setUp(self)
175 class Class(object):175 class Class:
176 __storm_table__ = "table"176 __storm_table__ = "table"
177 prop1 = Property("column1", primary=True)177 prop1 = Property("column1", primary=True)
178 prop2 = Property("column2")178 prop2 = Property("column2")
@@ -214,7 +214,7 @@
214 args = []214 args = []
215 def validator(obj, attr, value):215 def validator(obj, attr, value):
216 args.append((obj, attr, value))216 args.append((obj, attr, value))
217 class Class(object):217 class Class:
218 __storm_table__ = "table"218 __storm_table__ = "table"
219 prop = Property(primary=True,219 prop = Property(primary=True,
220 variable_kwargs={"validator": validator})220 variable_kwargs={"validator": validator})
@@ -522,7 +522,7 @@
522522
523 def setUp(self):523 def setUp(self):
524 TestHelper.setUp(self)524 TestHelper.setUp(self)
525 class Class(object):525 class Class:
526 __storm_table__ = "table"526 __storm_table__ = "table"
527 prop1 = Property("column1", primary=True)527 prop1 = Property("column1", primary=True)
528 self.Class = Class528 self.Class = Class
@@ -624,10 +624,10 @@
624624
625 def test_nested_classes(self):625 def test_nested_classes(self):
626 """Convoluted case checking that the model is right."""626 """Convoluted case checking that the model is right."""
627 class Class1(object):627 class Class1:
628 __storm_table__ = "class1"628 __storm_table__ = "class1"
629 id = Property(primary=True)629 id = Property(primary=True)
630 class Class2(object):630 class Class2:
631 __storm_table__ = Class1631 __storm_table__ = Class1
632 id = Property(primary=True)632 id = Property(primary=True)
633 statement = compile(Class2)633 statement = compile(Class2)
634634
=== modified file 'storm/tests/mocker.py'
--- storm/tests/mocker.py 2024-03-04 10:59:55 +0000
+++ storm/tests/mocker.py 2024-03-13 16:26:38 +0000
@@ -35,7 +35,7 @@
35# --------------------------------------------------------------------35# --------------------------------------------------------------------
36# Helper for chained-style calling.36# Helper for chained-style calling.
3737
38class expect(object):38class expect:
39 """This is a simple helper that allows a different call-style.39 """This is a simple helper that allows a different call-style.
4040
41 With this class one can comfortably do chaining of calls to the41 With this class one can comfortably do chaining of calls to the
@@ -136,7 +136,7 @@
136 self.__cleanup_funcs = []136 self.__cleanup_funcs = []
137 self.__cleanup_paths = []137 self.__cleanup_paths = []
138138
139 super(MockerTestCase, self).__init__(methodName)139 super().__init__(methodName)
140140
141 def __cleanup(self):141 def __cleanup(self):
142 for path in self.__cleanup_paths:142 for path in self.__cleanup_paths:
@@ -308,13 +308,13 @@
308308
309 if sys.version_info < (3, 2):309 if sys.version_info < (3, 2):
310 def assertRaisesRegex(self, *args, **kwargs):310 def assertRaisesRegex(self, *args, **kwargs):
311 return self.assertRaisesRegexp(*args, **kwargs)311 return self.assertRaisesRegex(*args, **kwargs)
312312
313313
314# --------------------------------------------------------------------314# --------------------------------------------------------------------
315# Mocker.315# Mocker.
316316
317class classinstancemethod(object):317class classinstancemethod:
318318
319 def __init__(self, method):319 def __init__(self, method):
320 self.method = method320 self.method = method
@@ -752,8 +752,7 @@
752 @param sequence: Sequence of values to be generated.752 @param sequence: Sequence of values to be generated.
753 """753 """
754 def generate(*args, **kwargs):754 def generate(*args, **kwargs):
755 for value in sequence:755 yield from sequence
756 yield value
757 self.call(generate)756 self.call(generate)
758757
759 def throw(self, exception):758 def throw(self, exception):
@@ -980,7 +979,7 @@
980 return self._events[0]979 return self._events[0]
981980
982981
983class OrderedContext(object):982class OrderedContext:
984983
985 def __init__(self, mocker):984 def __init__(self, mocker):
986 self._mocker = mocker985 self._mocker = mocker
@@ -1002,7 +1001,7 @@
1002# --------------------------------------------------------------------1001# --------------------------------------------------------------------
1003# Mock object.1002# Mock object.
10041003
1005class Mock(object):1004class Mock:
10061005
1007 def __init__(self, mocker, path=None, name=None, spec=None, type=None,1006 def __init__(self, mocker, path=None, name=None, spec=None, type=None,
1008 object=None, passthrough=False, patcher=None, count=True):1007 object=None, passthrough=False, patcher=None, count=True):
@@ -1044,7 +1043,7 @@
10441043
1045 def __getattribute__(self, name):1044 def __getattribute__(self, name):
1046 if name.startswith("__mocker_"):1045 if name.startswith("__mocker_"):
1047 return super(Mock, self).__getattribute__(name)1046 return super().__getattribute__(name)
1048 if name == "__class__":1047 if name == "__class__":
1049 if self.__mocker__.is_recording() or self.__mocker_type__ is None:1048 if self.__mocker__.is_recording() or self.__mocker_type__ is None:
1050 return type(self)1049 return type(self)
@@ -1053,7 +1052,7 @@
10531052
1054 def __setattr__(self, name, value):1053 def __setattr__(self, name, value):
1055 if name.startswith("__mocker_"):1054 if name.startswith("__mocker_"):
1056 return super(Mock, self).__setattr__(name, value)1055 return super().__setattr__(name, value)
1057 return self.__mocker_act__("setattr", (name, value))1056 return self.__mocker_act__("setattr", (name, value))
10581057
1059 def __delattr__(self, name):1058 def __delattr__(self, name):
@@ -1131,7 +1130,7 @@
1131# --------------------------------------------------------------------1130# --------------------------------------------------------------------
1132# Action and path.1131# Action and path.
11331132
1134class Action(object):1133class Action:
11351134
1136 def __init__(self, kind, args, kwargs, path=None):1135 def __init__(self, kind, args, kwargs, path=None):
1137 self.kind = kind1136 self.kind = kind
@@ -1200,7 +1199,7 @@
1200 return result1199 return result
12011200
12021201
1203class Path(object):1202class Path:
12041203
1205 def __init__(self, root_mock, root_object=None, actions=()):1204 def __init__(self, root_mock, root_object=None, actions=()):
1206 self.root_mock = root_mock1205 self.root_mock = root_mock
@@ -1293,7 +1292,7 @@
1293 return result1292 return result
12941293
12951294
1296class SpecialArgument(object):1295class SpecialArgument:
1297 """Base for special arguments for matching parameters."""1296 """Base for special arguments for matching parameters."""
12981297
1299 def __init__(self, object=None):1298 def __init__(self, object=None):
@@ -1450,7 +1449,7 @@
1450# --------------------------------------------------------------------1449# --------------------------------------------------------------------
1451# Event and task base.1450# Event and task base.
14521451
1453class Event(object):1452class Event:
1454 """Aggregation of tasks that keep track of a recorded action.1453 """Aggregation of tasks that keep track of a recorded action.
14551454
1456 An event represents something that may or may not happen while the1455 An event represents something that may or may not happen while the
@@ -1591,7 +1590,7 @@
1591 return False1590 return False
15921591
15931592
1594class Task(object):1593class Task:
1595 """Element used to track one specific aspect on an event.1594 """Element used to track one specific aspect on an event.
15961595
1597 A task is responsible for adding any kind of logic to an event.1596 A task is responsible for adding any kind of logic to an event.
@@ -1918,7 +1917,7 @@
1918 referrer[key] = install1917 referrer[key] = install
19191918
19201919
1921class Undefined(object):1920class Undefined:
19221921
1923 def __repr__(self):1922 def __repr__(self):
1924 return "Undefined"1923 return "Undefined"
@@ -1929,7 +1928,7 @@
1929class Patcher(Task):1928class Patcher(Task):
19301929
1931 def __init__(self):1930 def __init__(self):
1932 super(Patcher, self).__init__()1931 super().__init__()
1933 self._monitored = {} # {kind: {id(object): object}}1932 self._monitored = {} # {kind: {id(object): object}}
1934 self._patched = {}1933 self._patched = {}
19351934
@@ -1941,7 +1940,7 @@
1941 cls = type(obj)1940 cls = type(obj)
1942 if issubclass(cls, type):1941 if issubclass(cls, type):
1943 cls = obj1942 cls = obj
1944 bases = set([id(base) for base in cls.__mro__])1943 bases = {id(base) for base in cls.__mro__}
1945 bases.intersection_update(monitored)1944 bases.intersection_update(monitored)
1946 return bool(bases)1945 return bool(bases)
1947 return False1946 return False
@@ -2026,7 +2025,7 @@
2026 raise2025 raise
20272026
20282027
2029class PatchedMethod(object):2028class PatchedMethod:
20302029
2031 def __init__(self, kind, unpatched, is_monitoring):2030 def __init__(self, kind, unpatched, is_monitoring):
2032 self._kind = kind2031 self._kind = kind
20332032
=== modified file 'storm/tests/properties.py'
--- storm/tests/properties.py 2024-03-04 10:59:55 +0000
+++ storm/tests/properties.py 2024-03-13 16:26:38 +0000
@@ -45,7 +45,7 @@
4545
46 def setUp(self):46 def setUp(self):
47 TestHelper.setUp(self)47 TestHelper.setUp(self)
48 class Class(object):48 class Class:
49 __storm_table__ = "mytable"49 __storm_table__ = "mytable"
50 prop1 = Custom("column1", primary=True)50 prop1 = Custom("column1", primary=True)
51 prop2 = Custom()51 prop2 = Custom()
@@ -108,10 +108,10 @@
108 def test_variable_factory_validator_attribute(self):108 def test_variable_factory_validator_attribute(self):
109 # Should work even if we make things harder by reusing properties.109 # Should work even if we make things harder by reusing properties.
110 prop = Custom()110 prop = Custom()
111 class Class1(object):111 class Class1:
112 __storm_table__ = "table1"112 __storm_table__ = "table1"
113 prop1 = prop113 prop1 = prop
114 class Class2(object):114 class Class2:
115 __storm_table__ = "table2"115 __storm_table__ = "table2"
116 prop2 = prop116 prop2 = prop
117 args = []117 args = []
@@ -152,7 +152,7 @@
152 args[:] = obj, attr, value152 args[:] = obj, attr, value
153 return 42153 return 42
154154
155 class Class(object):155 class Class:
156 __storm_table__ = "mytable"156 __storm_table__ = "mytable"
157 prop = Custom("column", primary=True, validator=validator)157 prop = Custom("column", primary=True, validator=validator)
158158
@@ -299,10 +299,10 @@
299 right now it works, and we should try not to break it.299 right now it works, and we should try not to break it.
300 """300 """
301 prop = Custom()301 prop = Custom()
302 class Class1(object):302 class Class1:
303 __storm_table__ = "table1"303 __storm_table__ = "table1"
304 prop1 = prop304 prop1 = prop
305 class Class2(object):305 class Class2:
306 __storm_table__ = "table2"306 __storm_table__ = "table2"
307 prop2 = prop307 prop2 = prop
308 self.assertEqual(Class1.prop1.name, "prop1")308 self.assertEqual(Class1.prop1.name, "prop1")
@@ -316,7 +316,7 @@
316 def setup(self, property, *args, **kwargs):316 def setup(self, property, *args, **kwargs):
317 prop2_kwargs = kwargs.pop("prop2_kwargs", {})317 prop2_kwargs = kwargs.pop("prop2_kwargs", {})
318 kwargs["primary"] = True318 kwargs["primary"] = True
319 class Class(object):319 class Class:
320 __storm_table__ = "mytable"320 __storm_table__ = "mytable"
321 prop1 = property("column1", *args, **kwargs)321 prop1 = property("column1", *args, **kwargs)
322 prop2 = property(**prop2_kwargs)322 prop2 = property(**prop2_kwargs)
@@ -432,10 +432,10 @@
432 self.obj.prop2 = None432 self.obj.prop2 = None
433 self.assertEqual(self.obj.prop2, None)433 self.assertEqual(self.obj.prop2, None)
434434
435 self.assertRaises(TypeError, setattr, self.obj, "prop1", u"unicode")435 self.assertRaises(TypeError, setattr, self.obj, "prop1", "unicode")
436436
437 def test_unicode(self):437 def test_unicode(self):
438 self.setup(Unicode, default=u"def", allow_none=False)438 self.setup(Unicode, default="def", allow_none=False)
439439
440 self.assertTrue(isinstance(self.column1, Column))440 self.assertTrue(isinstance(self.column1, Column))
441 self.assertTrue(isinstance(self.column2, Column))441 self.assertTrue(isinstance(self.column2, Column))
@@ -446,7 +446,7 @@
446 self.assertTrue(isinstance(self.variable1, UnicodeVariable))446 self.assertTrue(isinstance(self.variable1, UnicodeVariable))
447 self.assertTrue(isinstance(self.variable2, UnicodeVariable))447 self.assertTrue(isinstance(self.variable2, UnicodeVariable))
448448
449 self.assertEqual(self.obj.prop1, u"def")449 self.assertEqual(self.obj.prop1, "def")
450 self.assertRaises(NoneError, setattr, self.obj, "prop1", None)450 self.assertRaises(NoneError, setattr, self.obj, "prop1", None)
451 self.obj.prop2 = None451 self.obj.prop2 = None
452 self.assertEqual(self.obj.prop2, None)452 self.assertEqual(self.obj.prop2, None)
@@ -798,7 +798,7 @@
798 self.assertEqual(changes, [(self.variable1, None, ["a"], False)])798 self.assertEqual(changes, [(self.variable1, None, ["a"], False)])
799799
800 def test_variable_factory_arguments(self):800 def test_variable_factory_arguments(self):
801 class Class(object):801 class Class:
802 __storm_table__ = "test"802 __storm_table__ = "test"
803 id = Int(primary=True)803 id = Int(primary=True)
804804
@@ -812,7 +812,7 @@
812 (Int, IntVariable, 1),812 (Int, IntVariable, 1),
813 (Float, FloatVariable, 1.1),813 (Float, FloatVariable, 1.1),
814 (Bytes, BytesVariable, b"str"),814 (Bytes, BytesVariable, b"str"),
815 (Unicode, UnicodeVariable, u"unicode"),815 (Unicode, UnicodeVariable, "unicode"),
816 (DateTime, DateTimeVariable, datetime.now()),816 (DateTime, DateTimeVariable, datetime.now()),
817 (Date, DateVariable, date.today()),817 (Date, DateVariable, date.today()),
818 (Time, TimeVariable, datetime.now().time()),818 (Time, TimeVariable, datetime.now().time()),
@@ -881,7 +881,7 @@
881 def setUp(self):881 def setUp(self):
882 TestHelper.setUp(self)882 TestHelper.setUp(self)
883883
884 class Class(object):884 class Class:
885 __storm_table__ = "mytable"885 __storm_table__ = "mytable"
886 prop1 = Property("column1", primary=True)886 prop1 = Property("column1", primary=True)
887 prop2 = Property()887 prop2 = Property()
888888
=== modified file 'storm/tests/schema/patch.py'
--- storm/tests/schema/patch.py 2024-03-04 10:59:55 +0000
+++ storm/tests/schema/patch.py 2024-03-13 16:26:38 +0000
@@ -75,7 +75,7 @@
75"""75"""
7676
7777
78class MockPatchStore(object):78class MockPatchStore:
7979
80 def __init__(self, database, patches=[]):80 def __init__(self, database, patches=[]):
81 self.database = database81 self.database = database
@@ -103,7 +103,7 @@
103class PatchApplierTest(MockerTestCase):103class PatchApplierTest(MockerTestCase):
104104
105 def setUp(self):105 def setUp(self):
106 super(PatchApplierTest, self).setUp()106 super().setUp()
107107
108 self.patchdir = self.makeDir()108 self.patchdir = self.makeDir()
109 self.pkgdir = os.path.join(self.patchdir, "mypackage")109 self.pkgdir = os.path.join(self.patchdir, "mypackage")
@@ -143,7 +143,7 @@
143 self.another_store.commit()143 self.another_store.commit()
144 self.prepare_for_transaction_check()144 self.prepare_for_transaction_check()
145145
146 class Committer(object):146 class Committer:
147147
148 def commit(committer):148 def commit(committer):
149 self.store.commit()149 self.store.commit()
@@ -158,7 +158,7 @@
158 self.committer)158 self.committer)
159159
160 def tearDown(self):160 def tearDown(self):
161 super(PatchApplierTest, self).tearDown()161 super().tearDown()
162 self.committer.rollback()162 self.committer.rollback()
163 sys.path.remove(self.patchdir)163 sys.path.remove(self.patchdir)
164 for name in list(sys.modules):164 for name in list(sys.modules):
@@ -329,7 +329,7 @@
329 patches = [Patch(42), Patch(380), Patch(381)]329 patches = [Patch(42), Patch(380), Patch(381)]
330 my_store = MockPatchStore("database", patches=patches)330 my_store = MockPatchStore("database", patches=patches)
331 patch_applier = PatchApplier(my_store, self.mypackage)331 patch_applier = PatchApplier(my_store, self.mypackage)
332 self.assertEqual(set([381]),332 self.assertEqual({381},
333 patch_applier.get_unknown_patch_versions())333 patch_applier.get_unknown_patch_versions())
334334
335 def test_no_unknown_patch_versions(self):335 def test_no_unknown_patch_versions(self):
@@ -410,7 +410,7 @@
410class PatchSetTest(MockerTestCase):410class PatchSetTest(MockerTestCase):
411411
412 def setUp(self):412 def setUp(self):
413 super(PatchSetTest, self).setUp()413 super().setUp()
414 self.sys_dir = self.makeDir()414 self.sys_dir = self.makeDir()
415 self.package_dir = os.path.join(self.sys_dir, "mypackage")415 self.package_dir = os.path.join(self.sys_dir, "mypackage")
416 os.makedirs(self.package_dir)416 os.makedirs(self.package_dir)
@@ -423,7 +423,7 @@
423 self.patch_package = PatchSet(mypackage, sub_level="foo")423 self.patch_package = PatchSet(mypackage, sub_level="foo")
424424
425 def tearDown(self):425 def tearDown(self):
426 super(PatchSetTest, self).tearDown()426 super().tearDown()
427 for name in list(sys.modules):427 for name in list(sys.modules):
428 if name == "mypackage" or name.startswith("mypackage."):428 if name == "mypackage" or name.startswith("mypackage."):
429 del sys.modules[name]429 del sys.modules[name]
430430
=== modified file 'storm/tests/schema/schema.py'
--- storm/tests/schema/schema.py 2024-03-04 10:59:55 +0000
+++ storm/tests/schema/schema.py 2024-03-13 16:26:38 +0000
@@ -27,7 +27,7 @@
27from storm.tests.mocker import MockerTestCase27from storm.tests.mocker import MockerTestCase
2828
2929
30class Package(object):30class Package:
3131
32 def __init__(self, package_dir, name):32 def __init__(self, package_dir, name):
33 self.name = name33 self.name = name
@@ -43,7 +43,7 @@
43class SchemaTest(MockerTestCase):43class SchemaTest(MockerTestCase):
4444
45 def setUp(self):45 def setUp(self):
46 super(SchemaTest, self).setUp()46 super().setUp()
47 self.database = create_database("sqlite:///%s" % self.makeFile())47 self.database = create_database("sqlite:///%s" % self.makeFile())
48 self.store = Store(self.database)48 self.store = Store(self.database)
4949
@@ -68,7 +68,7 @@
68 elif any(name.startswith("%s." % x) for x in self._package_names):68 elif any(name.startswith("%s." % x) for x in self._package_names):
69 del sys.modules[name]69 del sys.modules[name]
7070
71 super(SchemaTest, self).tearDown()71 super().tearDown()
7272
73 def create_package(self, base_dir, name, init_module=None):73 def create_package(self, base_dir, name, init_module=None):
74 """Create a Python package.74 """Create a Python package.
@@ -169,7 +169,7 @@
169 self.schema.create(self.store)169 self.schema.create(self.store)
170 self.store.execute("INSERT INTO person (id, name) VALUES (1, 'Jane')")170 self.store.execute("INSERT INTO person (id, name) VALUES (1, 'Jane')")
171 self.assertEqual(list(self.store.execute("SELECT * FROM person")),171 self.assertEqual(list(self.store.execute("SELECT * FROM person")),
172 [(1, u"Jane")])172 [(1, "Jane")])
173 self.schema.delete(self.store)173 self.schema.delete(self.store)
174 self.assertEqual(list(self.store.execute("SELECT * FROM person")), [])174 self.assertEqual(list(self.store.execute("SELECT * FROM person")), [])
175175
@@ -214,7 +214,7 @@
214 self.store.execute(214 self.store.execute(
215 "INSERT INTO person (id, name, phone) VALUES (1, 'Jane', '123')")215 "INSERT INTO person (id, name, phone) VALUES (1, 'Jane', '123')")
216 self.assertEqual(list(self.store.execute("SELECT * FROM person")),216 self.assertEqual(list(self.store.execute("SELECT * FROM person")),
217 [(1, u"Jane", u"123")])217 [(1, "Jane", "123")])
218218
219 def test_advance(self):219 def test_advance(self):
220 """220 """
@@ -235,4 +235,4 @@
235 self.store.execute(235 self.store.execute(
236 "INSERT INTO person (id, name, phone) VALUES (1, 'Jane', '123')")236 "INSERT INTO person (id, name, phone) VALUES (1, 'Jane', '123')")
237 self.assertEqual(list(self.store.execute("SELECT * FROM person")),237 self.assertEqual(list(self.store.execute("SELECT * FROM person")),
238 [(1, u"Jane", u"123")])238 [(1, "Jane", "123")])
239239
=== modified file 'storm/tests/schema/sharding.py'
--- storm/tests/schema/sharding.py 2024-03-04 10:59:55 +0000
+++ storm/tests/schema/sharding.py 2024-03-13 16:26:38 +0000
@@ -23,7 +23,7 @@
23from storm.tests.mocker import MockerTestCase23from storm.tests.mocker import MockerTestCase
2424
2525
26class FakeSchema(object):26class FakeSchema:
2727
28 patches = 228 patches = 2
2929
@@ -50,7 +50,7 @@
50 self.applied.append((store, store.patch))50 self.applied.append((store, store.patch))
5151
5252
53class FakeStore(object):53class FakeStore:
5454
55 pristine = True # If no schema was ever applied55 pristine = True # If no schema was ever applied
56 patch = 0 # Current patch level of the store56 patch = 0 # Current patch level of the store
@@ -59,7 +59,7 @@
59class ShardingTest(MockerTestCase):59class ShardingTest(MockerTestCase):
6060
61 def setUp(self):61 def setUp(self):
62 super(ShardingTest, self).setUp()62 super().setUp()
63 self.store = FakeStore()63 self.store = FakeStore()
64 self.schema = FakeSchema()64 self.schema = FakeSchema()
65 self.sharding = Sharding()65 self.sharding = Sharding()
6666
=== modified file 'storm/tests/sqlobject.py'
--- storm/tests/sqlobject.py 2024-03-04 10:59:55 +0000
+++ storm/tests/sqlobject.py 2024-03-13 16:26:38 +0000
@@ -343,7 +343,7 @@
343 self.assertEqual(nobody, None)343 self.assertEqual(nobody, None)
344344
345 # SQLBuilder style expression:345 # SQLBuilder style expression:
346 person = self.Person.selectFirst(LIKE(self.Person.q.name, u"John%"),346 person = self.Person.selectFirst(LIKE(self.Person.q.name, "John%"),
347 orderBy="name")347 orderBy="name")
348 self.assertNotEqual(person, None)348 self.assertNotEqual(person, None)
349 self.assertEqual(person.name, "John Doe")349 self.assertEqual(person.name, "John Doe")
@@ -463,8 +463,8 @@
463 class Person(self.SQLObject):463 class Person(self.SQLObject):
464 name = StringCol(storm_validator=validator)464 name = StringCol(storm_validator=validator)
465 person = Person.get(2)465 person = Person.get(2)
466 person.name = u'foo'466 person.name = 'foo'
467 self.assertEqual(calls, [(person, 'name', u'foo')])467 self.assertEqual(calls, [(person, 'name', 'foo')])
468468
469 def test_string_col(self):469 def test_string_col(self):
470 class Person(self.SQLObject):470 class Person(self.SQLObject):
@@ -1200,21 +1200,21 @@
1200 class Person(self.Person):1200 class Person(self.Person):
1201 def set(self, **kw):1201 def set(self, **kw):
1202 kw["id"] += 11202 kw["id"] += 1
1203 super(Person, self).set(**kw)1203 super().set(**kw)
1204 person = Person(id=3, name="John Moe")1204 person = Person(id=3, name="John Moe")
1205 self.assertEqual(person.id, 4)1205 self.assertEqual(person.id, 4)
1206 self.assertEqual(person.name, "John Moe")1206 self.assertEqual(person.name, "John Moe")
12071207
1208 def test_CONTAINSSTRING(self):1208 def test_CONTAINSSTRING(self):
1209 expr = CONTAINSSTRING(self.Person.q.name, u"Do")1209 expr = CONTAINSSTRING(self.Person.q.name, "Do")
1210 result = self.Person.select(expr)1210 result = self.Person.select(expr)
1211 self.assertEqual([person.name for person in result],1211 self.assertEqual([person.name for person in result],
1212 [u"John Doe"])1212 ["John Doe"])
12131213
1214 result[0].name = u"Funny !%_ Name"1214 result[0].name = "Funny !%_ Name"
12151215
1216 expr = NOT(CONTAINSSTRING(self.Person.q.name, u"!%_"))1216 expr = NOT(CONTAINSSTRING(self.Person.q.name, "!%_"))
1217 result = self.Person.select(expr)1217 result = self.Person.select(expr)
1218 self.assertEqual([person.name for person in result],1218 self.assertEqual([person.name for person in result],
1219 [u"John Joe"])1219 ["John Joe"])
12201220
12211221
=== modified file 'storm/tests/store/base.py'
--- storm/tests/store/base.py 2024-03-04 10:59:55 +0000
+++ storm/tests/store/base.py 2024-03-13 16:26:38 +0000
@@ -1,4 +1,3 @@
1# -*- coding: utf-8 -*-
2#1#
3# Copyright (c) 2006, 2007 Canonical2# Copyright (c) 2006, 2007 Canonical
4#3#
@@ -49,36 +48,36 @@
49from storm.tests.helper import TestHelper48from storm.tests.helper import TestHelper
5049
5150
52class Foo(object):51class Foo:
53 __storm_table__ = "foo"52 __storm_table__ = "foo"
54 id = Int(primary=True)53 id = Int(primary=True)
55 title = Unicode()54 title = Unicode()
5655
57class Bar(object):56class Bar:
58 __storm_table__ = "bar"57 __storm_table__ = "bar"
59 id = Int(primary=True)58 id = Int(primary=True)
60 title = Unicode()59 title = Unicode()
61 foo_id = Int()60 foo_id = Int()
62 foo = Reference(foo_id, Foo.id)61 foo = Reference(foo_id, Foo.id)
6362
64class UniqueID(object):63class UniqueID:
65 __storm_table__ = "unique_id"64 __storm_table__ = "unique_id"
66 id = UUID(primary=True)65 id = UUID(primary=True)
67 def __init__(self, id):66 def __init__(self, id):
68 self.id = id67 self.id = id
6968
70class Blob(object):69class Blob:
71 __storm_table__ = "bin"70 __storm_table__ = "bin"
72 id = Int(primary=True)71 id = Int(primary=True)
73 bin = Bytes()72 bin = Bytes()
7473
75class Link(object):74class Link:
76 __storm_table__ = "link"75 __storm_table__ = "link"
77 __storm_primary__ = "foo_id", "bar_id"76 __storm_primary__ = "foo_id", "bar_id"
78 foo_id = Int()77 foo_id = Int()
79 bar_id = Int()78 bar_id = Int()
8079
81class SelfRef(object):80class SelfRef:
82 __storm_table__ = "selfref"81 __storm_table__ = "selfref"
83 id = Int(primary=True)82 id = Int(primary=True)
84 title = Unicode()83 title = Unicode()
@@ -110,14 +109,14 @@
110 order_by=Bar.title)109 order_by=Bar.title)
111110
112111
113class FooValue(object):112class FooValue:
114 __storm_table__ = "foovalue"113 __storm_table__ = "foovalue"
115 id = Int(primary=True)114 id = Int(primary=True)
116 foo_id = Int()115 foo_id = Int()
117 value1 = Int()116 value1 = Int()
118 value2 = Int()117 value2 = Int()
119118
120class BarProxy(object):119class BarProxy:
121 __storm_table__ = "bar"120 __storm_table__ = "bar"
122 id = Int(primary=True)121 id = Int(primary=True)
123 title = Unicode()122 title = Unicode()
@@ -125,7 +124,7 @@
125 foo = Reference(foo_id, Foo.id)124 foo = Reference(foo_id, Foo.id)
126 foo_title = Proxy(foo, Foo.title)125 foo_title = Proxy(foo, Foo.title)
127126
128class Money(object):127class Money:
129 __storm_table__ = "money"128 __storm_table__ = "money"
130 id = Int(primary=True)129 id = Int(primary=True)
131 value = Decimal()130 value = Decimal()
@@ -134,17 +133,17 @@
134class DecorateVariable(Variable):133class DecorateVariable(Variable):
135134
136 def parse_get(self, value, to_db):135 def parse_get(self, value, to_db):
137 return u"to_%s(%s)" % (to_db and "db" or "py", value)136 return "to_%s(%s)" % (to_db and "db" or "py", value)
138137
139 def parse_set(self, value, from_db):138 def parse_set(self, value, from_db):
140 return u"from_%s(%s)" % (from_db and "db" or "py", value)139 return "from_%s(%s)" % (from_db and "db" or "py", value)
141140
142141
143class FooVariable(Foo):142class FooVariable(Foo):
144 title = Property(variable_class=DecorateVariable)143 title = Property(variable_class=DecorateVariable)
145144
146145
147class DummyDatabase(object):146class DummyDatabase:
148147
149 def connect(self, event=None):148 def connect(self, event=None):
150 return None149 return None
@@ -170,7 +169,7 @@
170 self.assertIdentical(store.get_database(), database)169 self.assertIdentical(store.get_database(), database)
171170
172171
173class StoreTest(object):172class StoreTest:
174173
175 def setUp(self):174 def setUp(self):
176 self.store = None175 self.store = None
@@ -307,7 +306,7 @@
307306
308 def test_execute_flushes(self):307 def test_execute_flushes(self):
309 foo = self.store.get(Foo, 10)308 foo = self.store.get(Foo, 10)
310 foo.title = u"New Title"309 foo.title = "New Title"
311310
312 result = self.store.execute("SELECT title FROM foo WHERE id=10")311 result = self.store.execute("SELECT title FROM foo WHERE id=10")
313 self.assertEqual(result.get_one(), ("New Title",))312 self.assertEqual(result.get_one(), ("New Title",))
@@ -373,13 +372,13 @@
373 # After adding an object, no references should be needed in372 # After adding an object, no references should be needed in
374 # python for it still to be added to the database.373 # python for it still to be added to the database.
375 foo = Foo()374 foo = Foo()
376 foo.title = u"live"375 foo.title = "live"
377 self.store.add(foo)376 self.store.add(foo)
378377
379 del foo378 del foo
380 gc.collect()379 gc.collect()
381380
382 self.assertTrue(self.store.find(Foo, title=u"live").one())381 self.assertTrue(self.store.find(Foo, title="live").one())
383382
384 def test_obj_info_with_deleted_object(self):383 def test_obj_info_with_deleted_object(self):
385 # Let's try to put Storm in trouble by killing the object384 # Let's try to put Storm in trouble by killing the object
@@ -524,14 +523,14 @@
524 store.523 store.
525 """524 """
526 foo = self.store.get(Foo, 20)525 foo = self.store.get(Foo, 20)
527 foo.title = u"changed"526 foo.title = "changed"
528 self.store.block_implicit_flushes()527 self.store.block_implicit_flushes()
529 foo2 = self.store.find(Foo, Foo.id == 20).one()528 foo2 = self.store.find(Foo, Foo.id == 20).one()
530 self.store.unblock_implicit_flushes()529 self.store.unblock_implicit_flushes()
531 self.store.commit()530 self.store.commit()
532531
533 foo3 = self.store.find(Foo, Foo.id == 20).one()532 foo3 = self.store.find(Foo, Foo.id == 20).one()
534 self.assertEqual(foo3.title, u"changed")533 self.assertEqual(foo3.title, "changed")
535534
536 def test_obj_info_with_deleted_object_with_get(self):535 def test_obj_info_with_deleted_object_with_get(self):
537 # Same thing, but using get rather than find.536 # Same thing, but using get rather than find.
@@ -559,7 +558,7 @@
559 self.get_cache(self.store).set_size(0)558 self.get_cache(self.store).set_size(0)
560559
561 foo = self.store.get(Foo, 20)560 foo = self.store.get(Foo, 20)
562 foo.title = u"Changed"561 foo.title = "Changed"
563 foo.tainted = True562 foo.tainted = True
564 obj_info = get_obj_info(foo)563 obj_info = get_obj_info(foo)
565564
@@ -571,11 +570,11 @@
571 def test_get_tuple(self):570 def test_get_tuple(self):
572 class MyFoo(Foo):571 class MyFoo(Foo):
573 __storm_primary__ = "title", "id"572 __storm_primary__ = "title", "id"
574 foo = self.store.get(MyFoo, (u"Title 30", 10))573 foo = self.store.get(MyFoo, ("Title 30", 10))
575 self.assertEqual(foo.id, 10)574 self.assertEqual(foo.id, 10)
576 self.assertEqual(foo.title, "Title 30")575 self.assertEqual(foo.title, "Title 30")
577576
578 foo = self.store.get(MyFoo, (u"Title 20", 10))577 foo = self.store.get(MyFoo, ("Title 20", 10))
579 self.assertEqual(foo, None)578 self.assertEqual(foo, None)
580579
581 def test_of(self):580 def test_of(self):
@@ -635,13 +634,13 @@
635634
636 def test_find_expr(self):635 def test_find_expr(self):
637 result = self.store.find(Foo, Foo.id == 20,636 result = self.store.find(Foo, Foo.id == 20,
638 Foo.title == u"Title 20")637 Foo.title == "Title 20")
639 self.assertEqual([(foo.id, foo.title) for foo in result], [638 self.assertEqual([(foo.id, foo.title) for foo in result], [
640 (20, "Title 20"),639 (20, "Title 20"),
641 ])640 ])
642641
643 result = self.store.find(Foo, Foo.id == 10,642 result = self.store.find(Foo, Foo.id == 10,
644 Foo.title == u"Title 20")643 Foo.title == "Title 20")
645 self.assertEqual([(foo.id, foo.title) for foo in result], [644 self.assertEqual([(foo.id, foo.title) for foo in result], [
646 ])645 ])
647646
@@ -654,12 +653,12 @@
654 self.assertEqual(foo.title, "Title 20")653 self.assertEqual(foo.title, "Title 20")
655654
656 def test_find_keywords(self):655 def test_find_keywords(self):
657 result = self.store.find(Foo, id=20, title=u"Title 20")656 result = self.store.find(Foo, id=20, title="Title 20")
658 self.assertEqual([(foo.id, foo.title) for foo in result], [657 self.assertEqual([(foo.id, foo.title) for foo in result], [
659 (20, u"Title 20")658 (20, "Title 20")
660 ])659 ])
661660
662 result = self.store.find(Foo, id=10, title=u"Title 20")661 result = self.store.find(Foo, id=10, title="Title 20")
663 self.assertEqual([(foo.id, foo.title) for foo in result], [662 self.assertEqual([(foo.id, foo.title) for foo in result], [
664 ])663 ])
665664
@@ -1053,7 +1052,7 @@
1053 self.assertTrue(isinstance(title, str))1052 self.assertTrue(isinstance(title, str))
10541053
1055 def test_find_max_with_empty_result_and_disallow_none(self):1054 def test_find_max_with_empty_result_and_disallow_none(self):
1056 class Bar(object):1055 class Bar:
1057 __storm_table__ = "bar"1056 __storm_table__ = "bar"
1058 id = Int(primary=True)1057 id = Int(primary=True)
1059 foo_id = Int(allow_none=False)1058 foo_id = Int(allow_none=False)
@@ -1074,7 +1073,7 @@
1074 self.assertTrue(isinstance(title, str))1073 self.assertTrue(isinstance(title, str))
10751074
1076 def test_find_min_with_empty_result_and_disallow_none(self):1075 def test_find_min_with_empty_result_and_disallow_none(self):
1077 class Bar(object):1076 class Bar:
1078 __storm_table__ = "bar"1077 __storm_table__ = "bar"
1079 id = Int(primary=True)1078 id = Int(primary=True)
1080 foo_id = Int(allow_none=False)1079 foo_id = Int(allow_none=False)
@@ -1092,7 +1091,7 @@
1092 def test_find_avg_float(self):1091 def test_find_avg_float(self):
1093 foo = Foo()1092 foo = Foo()
1094 foo.id = 151093 foo.id = 15
1095 foo.title = u"Title 15"1094 foo.title = "Title 15"
1096 self.store.add(foo)1095 self.store.add(foo)
1097 self.assertEqual(self.store.find(Foo).avg(Foo.id), 18.75)1096 self.assertEqual(self.store.find(Foo).avg(Foo.id), 18.75)
10981097
@@ -1103,7 +1102,7 @@
1103 self.assertEqual(self.store.find(Foo).sum(Foo.id * 2), 120)1102 self.assertEqual(self.store.find(Foo).sum(Foo.id * 2), 120)
11041103
1105 def test_find_sum_with_empty_result_and_disallow_none(self):1104 def test_find_sum_with_empty_result_and_disallow_none(self):
1106 class Bar(object):1105 class Bar:
1107 __storm_table__ = "bar"1106 __storm_table__ = "bar"
1108 id = Int(primary=True)1107 id = Int(primary=True)
1109 foo_id = Int(allow_none=False)1108 foo_id = Int(allow_none=False)
@@ -1203,7 +1202,7 @@
1203 self.assertTrue(foo1)1202 self.assertTrue(foo1)
1204 self.assertTrue(foo2)1203 self.assertTrue(foo2)
1205 self.assertTrue(bar)1204 self.assertTrue(bar)
1206 self.assertEqual(self.store.find(Foo, title=u"Title 20").cached(),1205 self.assertEqual(self.store.find(Foo, title="Title 20").cached(),
1207 [foo2])1206 [foo2])
12081207
1209 def test_find_cached_invalidated(self):1208 def test_find_cached_invalidated(self):
@@ -1217,7 +1216,7 @@
1217 self.store.invalidate(foo)1216 self.store.invalidate(foo)
1218 # Do not look for the primary key (id), since it's able to get1217 # Do not look for the primary key (id), since it's able to get
1219 # it without touching the database. Use the title instead.1218 # it without touching the database. Use the title instead.
1220 self.assertEqual(self.store.find(Foo, title=u"Title 20").cached(), [])1219 self.assertEqual(self.store.find(Foo, title="Title 20").cached(), [])
12211220
1222 def test_find_cached_with_info_alive_and_object_dead(self):1221 def test_find_cached_with_info_alive_and_object_dead(self):
1223 # Disable the cache, which holds strong references.1222 # Disable the cache, which holds strong references.
@@ -1242,8 +1241,8 @@
1242 lst = [bar and (bar.id, bar.title) for bar in result]1241 lst = [bar and (bar.id, bar.title) for bar in result]
1243 self.assertEqual(lst, [1242 self.assertEqual(lst, [
1244 None,1243 None,
1245 (200, u"Title 200"),1244 (200, "Title 200"),
1246 (300, u"Title 100"),1245 (300, "Title 100"),
1247 ])1246 ])
12481247
1249 def test_using_find_with_strings(self):1248 def test_using_find_with_strings(self):
@@ -1263,8 +1262,8 @@
1263 lst = [bar and (bar.id, bar.title) for bar in result]1262 lst = [bar and (bar.id, bar.title) for bar in result]
1264 self.assertEqual(lst, [1263 self.assertEqual(lst, [
1265 None,1264 None,
1266 (200, u"Title 200"),1265 (200, "Title 200"),
1267 (300, u"Title 100"),1266 (300, "Title 100"),
1268 ])1267 ])
12691268
1270 def test_find_tuple(self):1269 def test_find_tuple(self):
@@ -1276,8 +1275,8 @@
1276 lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title))1275 lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title))
1277 for (foo, bar) in result]1276 for (foo, bar) in result]
1278 self.assertEqual(lst, [1277 self.assertEqual(lst, [
1279 ((10, u"Title 30"), (100, u"Title 300")),1278 ((10, "Title 30"), (100, "Title 300")),
1280 ((30, u"Title 10"), (300, u"Title 100")),1279 ((30, "Title 10"), (300, "Title 100")),
1281 ])1280 ])
12821281
1283 def test_find_tuple_using(self):1282 def test_find_tuple_using(self):
@@ -1289,13 +1288,13 @@
1289 lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title))1288 lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title))
1290 for (foo, bar) in result]1289 for (foo, bar) in result]
1291 self.assertEqual(lst, [1290 self.assertEqual(lst, [
1292 ((10, u"Title 30"), (100, u"Title 300")),1291 ((10, "Title 30"), (100, "Title 300")),
1293 ((20, u"Title 20"), None),1292 ((20, "Title 20"), None),
1294 ((30, u"Title 10"), (300, u"Title 100")),1293 ((30, "Title 10"), (300, "Title 100")),
1295 ])1294 ])
12961295
1297 def test_find_tuple_using_with_disallow_none(self):1296 def test_find_tuple_using_with_disallow_none(self):
1298 class Bar(object):1297 class Bar:
1299 __storm_table__ = "bar"1298 __storm_table__ = "bar"
1300 id = Int(primary=True, allow_none=False)1299 id = Int(primary=True, allow_none=False)
1301 title = Unicode()1300 title = Unicode()
@@ -1310,9 +1309,9 @@
1310 lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title))1309 lst = [(foo and (foo.id, foo.title), bar and (bar.id, bar.title))
1311 for (foo, bar) in result]1310 for (foo, bar) in result]
1312 self.assertEqual(lst, [1311 self.assertEqual(lst, [
1313 ((10, u"Title 30"), (100, u"Title 300")),1312 ((10, "Title 30"), (100, "Title 300")),
1314 ((20, u"Title 20"), None),1313 ((20, "Title 20"), None),
1315 ((30, u"Title 10"), (300, u"Title 100")),1314 ((30, "Title 10"), (300, "Title 100")),
1316 ])1315 ])
13171316
1318 def test_find_tuple_using_skip_when_none(self):1317 def test_find_tuple_using_skip_when_none(self):
@@ -1327,11 +1326,11 @@
1327 link and (link.bar_id, link.foo_id))1326 link and (link.bar_id, link.foo_id))
1328 for (bar, link) in result]1327 for (bar, link) in result]
1329 self.assertEqual(lst, [1328 self.assertEqual(lst, [
1330 ((100, u"Title 300"), (100, 10)),1329 ((100, "Title 300"), (100, 10)),
1331 ((100, u"Title 300"), (100, 20)),1330 ((100, "Title 300"), (100, 20)),
1332 (None, None),1331 (None, None),
1333 ((300, u"Title 100"), (300, 10)),1332 ((300, "Title 100"), (300, 10)),
1334 ((300, u"Title 100"), (300, 30)),1333 ((300, "Title 100"), (300, 30)),
1335 ])1334 ])
13361335
1337 def test_find_tuple_contains(self):1336 def test_find_tuple_contains(self):
@@ -1362,9 +1361,9 @@
1362 result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id)1361 result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id)
1363 foo, bar = result.order_by(Foo.id).any()1362 foo, bar = result.order_by(Foo.id).any()
1364 self.assertEqual(foo.id, 10)1363 self.assertEqual(foo.id, 10)
1365 self.assertEqual(foo.title, u"Title 30")1364 self.assertEqual(foo.title, "Title 30")
1366 self.assertEqual(bar.id, 100)1365 self.assertEqual(bar.id, 100)
1367 self.assertEqual(bar.title, u"Title 300")1366 self.assertEqual(bar.title, "Title 300")
13681367
1369 def test_find_tuple_first(self):1368 def test_find_tuple_first(self):
1370 bar = self.store.get(Bar, 200)1369 bar = self.store.get(Bar, 200)
@@ -1373,9 +1372,9 @@
1373 result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id)1372 result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id)
1374 foo, bar = result.order_by(Foo.id).first()1373 foo, bar = result.order_by(Foo.id).first()
1375 self.assertEqual(foo.id, 10)1374 self.assertEqual(foo.id, 10)
1376 self.assertEqual(foo.title, u"Title 30")1375 self.assertEqual(foo.title, "Title 30")
1377 self.assertEqual(bar.id, 100)1376 self.assertEqual(bar.id, 100)
1378 self.assertEqual(bar.title, u"Title 300")1377 self.assertEqual(bar.title, "Title 300")
13791378
1380 def test_find_tuple_last(self):1379 def test_find_tuple_last(self):
1381 bar = self.store.get(Bar, 200)1380 bar = self.store.get(Bar, 200)
@@ -1384,9 +1383,9 @@
1384 result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id)1383 result = self.store.find((Foo, Bar), Bar.foo_id == Foo.id)
1385 foo, bar = result.order_by(Foo.id).last()1384 foo, bar = result.order_by(Foo.id).last()
1386 self.assertEqual(foo.id, 30)1385 self.assertEqual(foo.id, 30)
1387 self.assertEqual(foo.title, u"Title 10")1386 self.assertEqual(foo.title, "Title 10")
1388 self.assertEqual(bar.id, 300)1387 self.assertEqual(bar.id, 300)
1389 self.assertEqual(bar.title, u"Title 100")1388 self.assertEqual(bar.title, "Title 100")
13901389
1391 def test_find_tuple_one(self):1390 def test_find_tuple_one(self):
1392 bar = self.store.get(Bar, 200)1391 bar = self.store.get(Bar, 200)
@@ -1396,9 +1395,9 @@
1396 Bar.foo_id == Foo.id, Foo.id == 10)1395 Bar.foo_id == Foo.id, Foo.id == 10)
1397 foo, bar = result.order_by(Foo.id).one()1396 foo, bar = result.order_by(Foo.id).one()
1398 self.assertEqual(foo.id, 10)1397 self.assertEqual(foo.id, 10)
1399 self.assertEqual(foo.title, u"Title 30")1398 self.assertEqual(foo.title, "Title 30")
1400 self.assertEqual(bar.id, 100)1399 self.assertEqual(bar.id, 100)
1401 self.assertEqual(bar.title, u"Title 300")1400 self.assertEqual(bar.title, "Title 300")
14021401
1403 def test_find_tuple_count(self):1402 def test_find_tuple_count(self):
1404 bar = self.store.get(Bar, 200)1403 bar = self.store.get(Bar, 200)
@@ -1412,11 +1411,11 @@
14121411
1413 def test_find_tuple_set(self):1412 def test_find_tuple_set(self):
1414 result = self.store.find((Foo, Bar))1413 result = self.store.find((Foo, Bar))
1415 self.assertRaises(FeatureError, result.set, title=u"Title 40")1414 self.assertRaises(FeatureError, result.set, title="Title 40")
14161415
1417 def test_find_tuple_kwargs(self):1416 def test_find_tuple_kwargs(self):
1418 self.assertRaises(FeatureError,1417 self.assertRaises(FeatureError,
1419 self.store.find, (Foo, Bar), title=u"Title 10")1418 self.store.find, (Foo, Bar), title="Title 10")
14201419
1421 def test_find_tuple_cached(self):1420 def test_find_tuple_cached(self):
1422 result = self.store.find((Foo, Bar))1421 result = self.store.find((Foo, Bar))
@@ -1429,12 +1428,12 @@
1429 def test_find_with_expr(self):1428 def test_find_with_expr(self):
1430 result = self.store.find(Foo.title)1429 result = self.store.find(Foo.title)
1431 self.assertEqual(sorted(result),1430 self.assertEqual(sorted(result),
1432 [u"Title 10", u"Title 20", u"Title 30"])1431 ["Title 10", "Title 20", "Title 30"])
14331432
1434 def test_find_with_expr_uses_variable_set(self):1433 def test_find_with_expr_uses_variable_set(self):
1435 result = self.store.find(FooVariable.title,1434 result = self.store.find(FooVariable.title,
1436 FooVariable.id == 10)1435 FooVariable.id == 10)
1437 self.assertEqual(list(result), [u"to_py(from_db(Title 30))"])1436 self.assertEqual(list(result), ["to_py(from_db(Title 30))"])
14381437
1439 def test_find_tuple_with_expr(self):1438 def test_find_tuple_with_expr(self):
1440 result = self.store.find((Foo, Bar.id, Bar.title),1439 result = self.store.find((Foo, Bar.id, Bar.title),
@@ -1442,36 +1441,36 @@
1442 result.order_by(Foo.id)1441 result.order_by(Foo.id)
1443 self.assertEqual([(foo.id, foo.title, bar_id, bar_title)1442 self.assertEqual([(foo.id, foo.title, bar_id, bar_title)
1444 for foo, bar_id, bar_title in result],1443 for foo, bar_id, bar_title in result],
1445 [(10, u"Title 30", 100, u"Title 300"),1444 [(10, "Title 30", 100, "Title 300"),
1446 (20, u"Title 20", 200, u"Title 200"),1445 (20, "Title 20", 200, "Title 200"),
1447 (30, u"Title 10", 300, u"Title 100")])1446 (30, "Title 10", 300, "Title 100")])
14481447
1449 def test_find_using_with_expr(self):1448 def test_find_using_with_expr(self):
1450 result = self.store.using(Foo).find(Foo.title)1449 result = self.store.using(Foo).find(Foo.title)
1451 self.assertEqual(sorted(result),1450 self.assertEqual(sorted(result),
1452 [u"Title 10", u"Title 20", u"Title 30"])1451 ["Title 10", "Title 20", "Title 30"])
14531452
1454 def test_find_with_expr_contains(self):1453 def test_find_with_expr_contains(self):
1455 result = self.store.find(Foo.title)1454 result = self.store.find(Foo.title)
1456 self.assertEqual(u"Title 10" in result, True)1455 self.assertEqual("Title 10" in result, True)
1457 self.assertEqual(u"Title 42" in result, False)1456 self.assertEqual("Title 42" in result, False)
14581457
1459 def test_find_tuple_with_expr_contains(self):1458 def test_find_tuple_with_expr_contains(self):
1460 foo = self.store.get(Foo, 10)1459 foo = self.store.get(Foo, 10)
1461 result = self.store.find((Foo, Bar.title),1460 result = self.store.find((Foo, Bar.title),
1462 Bar.foo_id == Foo.id)1461 Bar.foo_id == Foo.id)
1463 self.assertEqual((foo, u"Title 300") in result, True)1462 self.assertEqual((foo, "Title 300") in result, True)
1464 self.assertEqual((foo, u"Title 100") in result, False)1463 self.assertEqual((foo, "Title 100") in result, False)
14651464
1466 def test_find_with_expr_contains_with_set_expression(self):1465 def test_find_with_expr_contains_with_set_expression(self):
1467 result1 = self.store.find(Foo.title)1466 result1 = self.store.find(Foo.title)
1468 result2 = self.store.find(Foo.title)1467 result2 = self.store.find(Foo.title)
1469 self.assertEqual(u"Title 10" in result1.union(result2), True)1468 self.assertEqual("Title 10" in result1.union(result2), True)
14701469
1471 if self.__class__.__name__.startswith("MySQL"):1470 if self.__class__.__name__.startswith("MySQL"):
1472 return1471 return
1473 self.assertEqual(u"Title 10" in result1.intersection(result2), True)1472 self.assertEqual("Title 10" in result1.intersection(result2), True)
1474 self.assertEqual(u"Title 10" in result1.difference(result2), False)1473 self.assertEqual("Title 10" in result1.difference(result2), False)
14751474
1476 def test_find_with_expr_remove_unsupported(self):1475 def test_find_with_expr_remove_unsupported(self):
1477 result = self.store.find(Foo.title)1476 result = self.store.find(Foo.title)
@@ -1492,12 +1491,12 @@
1492 def test_find_with_expr_values(self):1491 def test_find_with_expr_values(self):
1493 result = self.store.find(Foo.title)1492 result = self.store.find(Foo.title)
1494 self.assertEqual(sorted(result.values(Foo.title)),1493 self.assertEqual(sorted(result.values(Foo.title)),
1495 [u"Title 10", u"Title 20", u"Title 30"])1494 ["Title 10", "Title 20", "Title 30"])
14961495
1497 def test_find_tuple_with_expr_values(self):1496 def test_find_tuple_with_expr_values(self):
1498 result = self.store.find((Foo, Bar.title), Bar.foo_id == Foo.id)1497 result = self.store.find((Foo, Bar.title), Bar.foo_id == Foo.id)
1499 self.assertEqual(sorted(result.values(Foo.title)),1498 self.assertEqual(sorted(result.values(Foo.title)),
1500 [u"Title 10", u"Title 20", u"Title 30"])1499 ["Title 10", "Title 20", "Title 30"])
15011500
1502 def test_find_with_expr_set_unsupported(self):1501 def test_find_with_expr_set_unsupported(self):
1503 result = self.store.find(Foo.title)1502 result = self.store.find(Foo.title)
@@ -1520,7 +1519,7 @@
1520 result2 = self.store.find(Foo.title, Foo.id != 10)1519 result2 = self.store.find(Foo.title, Foo.id != 10)
1521 result = result1.union(result2)1520 result = result1.union(result2)
1522 self.assertEqual(sorted(result),1521 self.assertEqual(sorted(result),
1523 [u"Title 10", u"Title 20", u"Title 30",])1522 ["Title 10", "Title 20", "Title 30",])
15241523
1525 def test_find_with_expr_union_mismatch(self):1524 def test_find_with_expr_union_mismatch(self):
1526 result1 = self.store.find(Foo.title)1525 result1 = self.store.find(Foo.title)
@@ -1529,19 +1528,19 @@
15291528
1530 def test_find_tuple_with_expr_union(self):1529 def test_find_tuple_with_expr_union(self):
1531 result1 = self.store.find(1530 result1 = self.store.find(
1532 (Foo, Bar.title), Bar.foo_id == Foo.id, Bar.title == u"Title 100")1531 (Foo, Bar.title), Bar.foo_id == Foo.id, Bar.title == "Title 100")
1533 result2 = self.store.find(1532 result2 = self.store.find(
1534 (Foo, Bar.title), Bar.foo_id == Foo.id, Bar.title == u"Title 200")1533 (Foo, Bar.title), Bar.foo_id == Foo.id, Bar.title == "Title 200")
1535 result = result1.union(result2)1534 result = result1.union(result2)
1536 self.assertEqual(sorted((foo.id, title) for (foo, title) in result),1535 self.assertEqual(sorted((foo.id, title) for (foo, title) in result),
1537 [(20, u"Title 200"), (30, u"Title 100")])1536 [(20, "Title 200"), (30, "Title 100")])
15381537
1539 def test_get_does_not_validate(self):1538 def test_get_does_not_validate(self):
1540 def validator(object, attr, value):1539 def validator(object, attr, value):
1541 self.fail("validator called with arguments (%r, %r, %r)" %1540 self.fail("validator called with arguments (%r, %r, %r)" %
1542 (object, attr, value))1541 (object, attr, value))
15431542
1544 class Foo(object):1543 class Foo:
1545 __storm_table__ = "foo"1544 __storm_table__ = "foo"
1546 id = Int(primary=True)1545 id = Int(primary=True)
1547 title = Unicode(validator=validator)1546 title = Unicode(validator=validator)
@@ -1554,10 +1553,10 @@
1554 self.fail("validator called with arguments (%r, %r, %r)" %1553 self.fail("validator called with arguments (%r, %r, %r)" %
1555 (object, attr, value))1554 (object, attr, value))
15561555
1557 class Foo(object):1556 class Foo:
1558 __storm_table__ = "foo"1557 __storm_table__ = "foo"
1559 id = Int(primary=True)1558 id = Int(primary=True)
1560 title = Unicode(validator=validator, default=u"default value")1559 title = Unicode(validator=validator, default="default value")
15611560
1562 foo = self.store.get(Foo, 10)1561 foo = self.store.get(Foo, 10)
1563 self.assertEqual(foo.title, "Title 30")1562 self.assertEqual(foo.title, "Title 30")
@@ -1567,7 +1566,7 @@
1567 self.fail("validator called with arguments (%r, %r, %r)" %1566 self.fail("validator called with arguments (%r, %r, %r)" %
1568 (object, attr, value))1567 (object, attr, value))
15691568
1570 class Foo(object):1569 class Foo:
1571 __storm_table__ = "foo"1570 __storm_table__ = "foo"
1572 id = Int(primary=True)1571 id = Int(primary=True)
1573 title = Unicode(validator=validator)1572 title = Unicode(validator=validator)
@@ -1682,7 +1681,7 @@
1682 result.group_by(Foo)1681 result.group_by(Foo)
1683 result.order_by(Foo.title)1682 result.order_by(Foo.title)
1684 result = list(result.values(Foo.title))1683 result = list(result.values(Foo.title))
1685 self.assertEqual(result, [u'Title 20', u'Title 30'])1684 self.assertEqual(result, ['Title 20', 'Title 30'])
16861685
1687 def test_find_group_by_union(self):1686 def test_find_group_by_union(self):
1688 result1 = self.store.find(Foo, id=30)1687 result1 = self.store.find(Foo, id=30)
@@ -1703,7 +1702,7 @@
1703 def test_add_commit(self):1702 def test_add_commit(self):
1704 foo = Foo()1703 foo = Foo()
1705 foo.id = 401704 foo.id = 40
1706 foo.title = u"Title 40"1705 foo.title = "Title 40"
17071706
1708 self.store.add(foo)1707 self.store.add(foo)
17091708
@@ -1725,7 +1724,7 @@
1725 def test_add_rollback_commit(self):1724 def test_add_rollback_commit(self):
1726 foo = Foo()1725 foo = Foo()
1727 foo.id = 401726 foo.id = 40
1728 foo.title = u"Title 40"1727 foo.title = "Title 40"
17291728
1730 self.store.add(foo)1729 self.store.add(foo)
1731 self.store.rollback()1730 self.store.rollback()
@@ -1749,7 +1748,7 @@
1749 def test_add_get(self):1748 def test_add_get(self):
1750 foo = Foo()1749 foo = Foo()
1751 foo.id = 401750 foo.id = 40
1752 foo.title = u"Title 40"1751 foo.title = "Title 40"
17531752
1754 self.store.add(foo)1753 self.store.add(foo)
17551754
@@ -1765,7 +1764,7 @@
1765 def test_add_find(self):1764 def test_add_find(self):
1766 foo = Foo()1765 foo = Foo()
1767 foo.id = 401766 foo.id = 40
1768 foo.title = u"Title 40"1767 foo.title = "Title 40"
17691768
1770 self.store.add(foo)1769 self.store.add(foo)
17711770
@@ -1799,7 +1798,7 @@
1799 self.store.add(bar)1798 self.store.add(bar)
18001799
1801 bar.id = 4001800 bar.id = 400
1802 bar.title = u"Title 400"1801 bar.title = "Title 400"
1803 bar.foo_id = 401802 bar.foo_id = 40
18041803
1805 self.store.flush()1804 self.store.flush()
@@ -1817,7 +1816,7 @@
1817 self.store.add(foo)1816 self.store.add(foo)
1818 self.store.flush()1817 self.store.flush()
1819 self.assertEqual(type(foo.id), int)1818 self.assertEqual(type(foo.id), int)
1820 self.assertEqual(foo.title, u"Default Title")1819 self.assertEqual(foo.title, "Default Title")
18211820
1822 def test_add_uuid(self):1821 def test_add_uuid(self):
1823 unique_id = self.store.add(UniqueID(uuid4()))1822 unique_id = self.store.add(UniqueID(uuid4()))
@@ -1854,7 +1853,7 @@
1854 self.store.remove(foo)1853 self.store.remove(foo)
1855 self.store.rollback()1854 self.store.rollback()
18561855
1857 foo.title = u"Title 200"1856 foo.title = "Title 200"
18581857
1859 self.store.flush()1858 self.store.flush()
18601859
@@ -1871,7 +1870,7 @@
1871 self.store.flush()1870 self.store.flush()
1872 self.store.rollback()1871 self.store.rollback()
18731872
1874 foo.title = u"Title 200"1873 foo.title = "Title 200"
18751874
1876 self.store.flush()1875 self.store.flush()
18771876
@@ -1887,7 +1886,7 @@
1887 self.store.remove(foo)1886 self.store.remove(foo)
1888 self.store.add(foo)1887 self.store.add(foo)
18891888
1890 foo.title = u"Title 200"1889 foo.title = "Title 200"
18911890
1892 self.store.flush()1891 self.store.flush()
18931892
@@ -1904,7 +1903,7 @@
1904 self.store.flush()1903 self.store.flush()
1905 self.store.add(foo)1904 self.store.add(foo)
19061905
1907 foo.title = u"Title 200"1906 foo.title = "Title 200"
19081907
1909 self.store.flush()1908 self.store.flush()
19101909
@@ -1933,7 +1932,7 @@
1933 self.store.remove(foo)1932 self.store.remove(foo)
1934 self.store.flush()1933 self.store.flush()
19351934
1936 foo.title = u"Title 200"1935 foo.title = "Title 200"
19371936
1938 self.assertTrue(obj_info not in self.store._dirty)1937 self.assertTrue(obj_info not in self.store._dirty)
19391938
@@ -1957,7 +1956,7 @@
1957 def test_add_rollback_not_in_store(self):1956 def test_add_rollback_not_in_store(self):
1958 foo = Foo()1957 foo = Foo()
1959 foo.id = 401958 foo.id = 40
1960 foo.title = u"Title 40"1959 foo.title = "Title 40"
19611960
1962 self.store.add(foo)1961 self.store.add(foo)
1963 self.store.rollback()1962 self.store.rollback()
@@ -1966,7 +1965,7 @@
19661965
1967 def test_update_flush_commit(self):1966 def test_update_flush_commit(self):
1968 foo = self.store.get(Foo, 20)1967 foo = self.store.get(Foo, 20)
1969 foo.title = u"Title 200"1968 foo.title = "Title 200"
19701969
1971 self.assertEqual(self.get_items(), [1970 self.assertEqual(self.get_items(), [
1972 (10, "Title 30"),1971 (10, "Title 30"),
@@ -2002,7 +2001,7 @@
20022001
2003 def test_update_flush_reload_rollback(self):2002 def test_update_flush_reload_rollback(self):
2004 foo = self.store.get(Foo, 20)2003 foo = self.store.get(Foo, 20)
2005 foo.title = u"Title 200"2004 foo.title = "Title 200"
2006 self.store.flush()2005 self.store.flush()
2007 self.store.reload(foo)2006 self.store.reload(foo)
2008 self.store.rollback()2007 self.store.rollback()
@@ -2010,7 +2009,7 @@
20102009
2011 def test_update_commit(self):2010 def test_update_commit(self):
2012 foo = self.store.get(Foo, 20)2011 foo = self.store.get(Foo, 20)
2013 foo.title = u"Title 200"2012 foo.title = "Title 200"
20142013
2015 self.store.commit()2014 self.store.commit()
20162015
@@ -2022,9 +2021,9 @@
20222021
2023 def test_update_commit_twice(self):2022 def test_update_commit_twice(self):
2024 foo = self.store.get(Foo, 20)2023 foo = self.store.get(Foo, 20)
2025 foo.title = u"Title 200"2024 foo.title = "Title 200"
2026 self.store.commit()2025 self.store.commit()
2027 foo.title = u"Title 2000"2026 foo.title = "Title 2000"
2028 self.store.commit()2027 self.store.commit()
20292028
2030 self.assertEqual(self.get_committed_items(), [2029 self.assertEqual(self.get_committed_items(), [
@@ -2035,7 +2034,7 @@
20352034
2036 def test_update_checkpoints(self):2035 def test_update_checkpoints(self):
2037 bar = self.store.get(Bar, 200)2036 bar = self.store.get(Bar, 200)
2038 bar.title = u"Title 400"2037 bar.title = "Title 400"
2039 self.store.flush()2038 self.store.flush()
2040 self.store.execute("UPDATE bar SET title='Title 500' "2039 self.store.execute("UPDATE bar SET title='Title 500' "
2041 "WHERE id=200")2040 "WHERE id=200")
@@ -2099,7 +2098,7 @@
20992098
2100 def test_wb_update_not_dirty_after_flush(self):2099 def test_wb_update_not_dirty_after_flush(self):
2101 foo = self.store.get(Foo, 20)2100 foo = self.store.get(Foo, 20)
2102 foo.title = u"Title 200"2101 foo.title = "Title 200"
21032102
2104 self.store.flush()2103 self.store.flush()
21052104
@@ -2108,7 +2107,7 @@
21082107
2109 self.store._disable_change_notification(get_obj_info(foo))2108 self.store._disable_change_notification(get_obj_info(foo))
21102109
2111 foo.title = u"Title 2000"2110 foo.title = "Title 2000"
21122111
2113 self.store.flush()2112 self.store.flush()
21142113
@@ -2120,9 +2119,9 @@
21202119
2121 def test_update_find(self):2120 def test_update_find(self):
2122 foo = self.store.get(Foo, 20)2121 foo = self.store.get(Foo, 20)
2123 foo.title = u"Title 200"2122 foo.title = "Title 200"
21242123
2125 result = self.store.find(Foo, Foo.title == u"Title 200")2124 result = self.store.find(Foo, Foo.title == "Title 200")
21262125
2127 self.assertTrue(result.one() is foo)2126 self.assertTrue(result.one() is foo)
21282127
@@ -2135,11 +2134,11 @@
2135 def test_add_update(self):2134 def test_add_update(self):
2136 foo = Foo()2135 foo = Foo()
2137 foo.id = 402136 foo.id = 40
2138 foo.title = u"Title 40"2137 foo.title = "Title 40"
21392138
2140 self.store.add(foo)2139 self.store.add(foo)
21412140
2142 foo.title = u"Title 400"2141 foo.title = "Title 400"
21432142
2144 self.store.flush()2143 self.store.flush()
21452144
@@ -2153,14 +2152,14 @@
2153 def test_add_remove_add(self):2152 def test_add_remove_add(self):
2154 foo = Foo()2153 foo = Foo()
2155 foo.id = 402154 foo.id = 40
2156 foo.title = u"Title 40"2155 foo.title = "Title 40"
21572156
2158 self.store.add(foo)2157 self.store.add(foo)
2159 self.store.remove(foo)2158 self.store.remove(foo)
21602159
2161 self.assertEqual(Store.of(foo), None)2160 self.assertEqual(Store.of(foo), None)
21622161
2163 foo.title = u"Title 400"2162 foo.title = "Title 400"
21642163
2165 self.store.add(foo)2164 self.store.add(foo)
21662165
@@ -2192,7 +2191,7 @@
21922191
2193 def test_wb_update_remove_add(self):2192 def test_wb_update_remove_add(self):
2194 foo = self.store.get(Foo, 20)2193 foo = self.store.get(Foo, 20)
2195 foo.title = u"Title 200"2194 foo.title = "Title 200"
21962195
2197 obj_info = get_obj_info(foo)2196 obj_info = get_obj_info(foo)
21982197
@@ -2246,14 +2245,14 @@
22462245
2247 def test_join(self):2246 def test_join(self):
22482247
2249 class Bar(object):2248 class Bar:
2250 __storm_table__ = "bar"2249 __storm_table__ = "bar"
2251 id = Int(primary=True)2250 id = Int(primary=True)
2252 title = Unicode()2251 title = Unicode()
22532252
2254 bar = Bar()2253 bar = Bar()
2255 bar.id = 402254 bar.id = 40
2256 bar.title = u"Title 20"2255 bar.title = "Title 20"
22572256
2258 self.store.add(bar)2257 self.store.add(bar)
22592258
@@ -2262,7 +2261,7 @@
22622261
2263 bar = Bar()2262 bar = Bar()
2264 bar.id = 4002263 bar.id = 400
2265 bar.title = u"Title 20"2264 bar.title = "Title 20"
22662265
2267 self.store.add(bar)2266 self.store.add(bar)
22682267
@@ -2275,14 +2274,14 @@
22752274
2276 def test_join_distinct(self):2275 def test_join_distinct(self):
22772276
2278 class Bar(object):2277 class Bar:
2279 __storm_table__ = "bar"2278 __storm_table__ = "bar"
2280 id = Int(primary=True)2279 id = Int(primary=True)
2281 title = Unicode()2280 title = Unicode()
22822281
2283 bar = Bar()2282 bar = Bar()
2284 bar.id = 402283 bar.id = 40
2285 bar.title = u"Title 20"2284 bar.title = "Title 20"
22862285
2287 self.store.add(bar)2286 self.store.add(bar)
22882287
@@ -2291,7 +2290,7 @@
22912290
2292 bar = Bar()2291 bar = Bar()
2293 bar.id = 4002292 bar.id = 400
2294 bar.title = u"Title 20"2293 bar.title = "Title 20"
22952294
2296 self.store.add(bar)2295 self.store.add(bar)
22972296
@@ -2330,7 +2329,7 @@
23302329
2331 foo = Foo()2330 foo = Foo()
2332 foo.id = 202331 foo.id = 20
2333 foo.title = u"Readded"2332 foo.title = "Readded"
2334 self.store.add(foo)2333 self.store.add(foo)
23352334
2336 self.store.commit()2335 self.store.commit()
@@ -2346,7 +2345,7 @@
2346 loaded.append("NO!")2345 loaded.append("NO!")
2347 def __storm_loaded__(self):2346 def __storm_loaded__(self):
2348 loaded.append((self.id, self.title))2347 loaded.append((self.id, self.title))
2349 self.title = u"Title 200"2348 self.title = "Title 200"
2350 self.some_attribute = 12349 self.some_attribute = 1
23512350
2352 foo = self.store.get(MyFoo, 20)2351 foo = self.store.get(MyFoo, 20)
@@ -2376,7 +2375,7 @@
2376 counter = 02375 counter = 0
2377 def __storm_pre_flush__(self):2376 def __storm_pre_flush__(self):
2378 if self.counter == 0:2377 if self.counter == 0:
2379 self.title = u"Flushing: %s" % self.title2378 self.title = "Flushing: %s" % self.title
2380 self.counter += 12379 self.counter += 1
23812380
2382 foo = self.store.get(MyFoo, 20)2381 foo = self.store.get(MyFoo, 20)
@@ -2384,7 +2383,7 @@
2384 self.assertEqual(foo.title, "Title 20")2383 self.assertEqual(foo.title, "Title 20")
2385 self.store.flush()2384 self.store.flush()
2386 self.assertEqual(foo.title, "Title 20") # It wasn't dirty.2385 self.assertEqual(foo.title, "Title 20") # It wasn't dirty.
2387 foo.title = u"Something"2386 foo.title = "Something"
2388 self.store.flush()2387 self.store.flush()
2389 self.assertEqual(foo.title, "Flushing: Something")2388 self.assertEqual(foo.title, "Flushing: Something")
23902389
@@ -2407,11 +2406,11 @@
2407 class MyFoo(Foo):2406 class MyFoo(Foo):
2408 def __storm_pre_flush__(self):2407 def __storm_pre_flush__(self):
2409 other = [foo1, foo2][foo1 is self]2408 other = [foo1, foo2][foo1 is self]
2410 other.title = u"Changed in hook: " + other.title2409 other.title = "Changed in hook: " + other.title
24112410
2412 foo1 = self.store.get(MyFoo, 10)2411 foo1 = self.store.get(MyFoo, 10)
2413 foo2 = self.store.get(MyFoo, 20)2412 foo2 = self.store.get(MyFoo, 20)
2414 foo1.title = u"Changed"2413 foo1.title = "Changed"
2415 self.store.flush()2414 self.store.flush()
24162415
2417 self.assertEqual(foo1.title, "Changed in hook: Changed")2416 self.assertEqual(foo1.title, "Changed in hook: Changed")
@@ -2424,14 +2423,14 @@
2424 def __storm_flushed__(self):2423 def __storm_flushed__(self):
2425 if not self.done:2424 if not self.done:
2426 self.done = True2425 self.done = True
2427 self.title = u"Flushed: %s" % self.title2426 self.title = "Flushed: %s" % self.title
24282427
2429 foo = self.store.get(MyFoo, 20)2428 foo = self.store.get(MyFoo, 20)
24302429
2431 self.assertEqual(foo.title, "Title 20")2430 self.assertEqual(foo.title, "Title 20")
2432 self.store.flush()2431 self.store.flush()
2433 self.assertEqual(foo.title, "Title 20") # It wasn't dirty.2432 self.assertEqual(foo.title, "Title 20") # It wasn't dirty.
2434 foo.title = u"Something"2433 foo.title = "Something"
2435 self.store.flush()2434 self.store.flush()
2436 self.assertEqual(foo.title, "Flushed: Something")2435 self.assertEqual(foo.title, "Flushed: Something")
24372436
@@ -2451,7 +2450,7 @@
24512450
2452 def test_retrieve_default_primary_key(self):2451 def test_retrieve_default_primary_key(self):
2453 foo = Foo()2452 foo = Foo()
2454 foo.title = u"Title 40"2453 foo.title = "Title 40"
2455 self.store.add(foo)2454 self.store.add(foo)
2456 self.store.flush()2455 self.store.flush()
2457 self.assertNotEqual(foo.id, None)2456 self.assertNotEqual(foo.id, None)
@@ -2568,13 +2567,13 @@
2568 def test_reload_new(self):2567 def test_reload_new(self):
2569 foo = Foo()2568 foo = Foo()
2570 foo.id = 402569 foo.id = 40
2571 foo.title = u"Title 40"2570 foo.title = "Title 40"
2572 self.assertRaises(WrongStoreError, self.store.reload, foo)2571 self.assertRaises(WrongStoreError, self.store.reload, foo)
25732572
2574 def test_reload_new_unflushed(self):2573 def test_reload_new_unflushed(self):
2575 foo = Foo()2574 foo = Foo()
2576 foo.id = 402575 foo.id = 40
2577 foo.title = u"Title 40"2576 foo.title = "Title 40"
2578 self.store.add(foo)2577 self.store.add(foo)
2579 self.assertRaises(NotFlushedError, self.store.reload, foo)2578 self.assertRaises(NotFlushedError, self.store.reload, foo)
25802579
@@ -2592,43 +2591,43 @@
2592 def test_wb_reload_not_dirty(self):2591 def test_wb_reload_not_dirty(self):
2593 foo = self.store.get(Foo, 20)2592 foo = self.store.get(Foo, 20)
2594 obj_info = get_obj_info(foo)2593 obj_info = get_obj_info(foo)
2595 foo.title = u"Title 40"2594 foo.title = "Title 40"
2596 self.store.reload(foo)2595 self.store.reload(foo)
2597 self.assertTrue(obj_info not in self.store._dirty)2596 self.assertTrue(obj_info not in self.store._dirty)
25982597
2599 def test_find_set_empty(self):2598 def test_find_set_empty(self):
2600 self.store.find(Foo, title=u"Title 20").set()2599 self.store.find(Foo, title="Title 20").set()
2601 foo = self.store.get(Foo, 20)2600 foo = self.store.get(Foo, 20)
2602 self.assertEqual(foo.title, "Title 20")2601 self.assertEqual(foo.title, "Title 20")
26032602
2604 def test_find_set(self):2603 def test_find_set(self):
2605 self.store.find(Foo, title=u"Title 20").set(title=u"Title 40")2604 self.store.find(Foo, title="Title 20").set(title="Title 40")
2606 foo = self.store.get(Foo, 20)2605 foo = self.store.get(Foo, 20)
2607 self.assertEqual(foo.title, "Title 40")2606 self.assertEqual(foo.title, "Title 40")
26082607
2609 def test_find_set_with_func_expr(self):2608 def test_find_set_with_func_expr(self):
2610 self.store.find(Foo, title=u"Title 20").set(title=Lower(u"Title 40"))2609 self.store.find(Foo, title="Title 20").set(title=Lower("Title 40"))
2611 foo = self.store.get(Foo, 20)2610 foo = self.store.get(Foo, 20)
2612 self.assertEqual(foo.title, "title 40")2611 self.assertEqual(foo.title, "title 40")
26132612
2614 def test_find_set_equality_with_func_expr(self):2613 def test_find_set_equality_with_func_expr(self):
2615 self.store.find(Foo, title=u"Title 20").set(2614 self.store.find(Foo, title="Title 20").set(
2616 Foo.title == Lower(u"Title 40"))2615 Foo.title == Lower("Title 40"))
2617 foo = self.store.get(Foo, 20)2616 foo = self.store.get(Foo, 20)
2618 self.assertEqual(foo.title, "title 40")2617 self.assertEqual(foo.title, "title 40")
26192618
2620 def test_find_set_column(self):2619 def test_find_set_column(self):
2621 self.store.find(Bar, title=u"Title 200").set(foo_id=Bar.id)2620 self.store.find(Bar, title="Title 200").set(foo_id=Bar.id)
2622 bar = self.store.get(Bar, 200)2621 bar = self.store.get(Bar, 200)
2623 self.assertEqual(bar.foo_id, 200)2622 self.assertEqual(bar.foo_id, 200)
26242623
2625 def test_find_set_expr(self):2624 def test_find_set_expr(self):
2626 self.store.find(Foo, title=u"Title 20").set(Foo.title == u"Title 40")2625 self.store.find(Foo, title="Title 20").set(Foo.title == "Title 40")
2627 foo = self.store.get(Foo, 20)2626 foo = self.store.get(Foo, 20)
2628 self.assertEqual(foo.title, "Title 40")2627 self.assertEqual(foo.title, "Title 40")
26292628
2630 def test_find_set_none(self):2629 def test_find_set_none(self):
2631 self.store.find(Foo, title=u"Title 20").set(title=None)2630 self.store.find(Foo, title="Title 20").set(title=None)
2632 foo = self.store.get(Foo, 20)2631 foo = self.store.get(Foo, 20)
2633 self.assertEqual(foo.title, None)2632 self.assertEqual(foo.title, None)
26342633
@@ -2653,7 +2652,7 @@
26532652
2654 def test_find_set_none_on_cached(self):2653 def test_find_set_none_on_cached(self):
2655 foo = self.store.get(Foo, 20)2654 foo = self.store.get(Foo, 20)
2656 self.store.find(Foo, title=u"Title 20").set(title=None)2655 self.store.find(Foo, title="Title 20").set(title=None)
2657 self.assertEqual(foo.title, None)2656 self.assertEqual(foo.title, None)
26582657
2659 def test_find_set_on_cached_but_removed(self):2658 def test_find_set_on_cached_but_removed(self):
@@ -2668,27 +2667,27 @@
2668 foo1 = self.store.get(Foo, 20)2667 foo1 = self.store.get(Foo, 20)
2669 foo2 = self.store.get(Foo, 30)2668 foo2 = self.store.get(Foo, 30)
2670 self.store.find(2669 self.store.find(
2671 Foo, Foo.id == Select(SQL("20"))).set(title=u"Title 40")2670 Foo, Foo.id == Select(SQL("20"))).set(title="Title 40")
2672 self.assertEqual(foo1.title, "Title 40")2671 self.assertEqual(foo1.title, "Title 40")
2673 self.assertEqual(foo2.title, "Title 10")2672 self.assertEqual(foo2.title, "Title 10")
26742673
2675 def test_find_set_expr_unsupported(self):2674 def test_find_set_expr_unsupported(self):
2676 result = self.store.find(Foo, title=u"Title 20")2675 result = self.store.find(Foo, title="Title 20")
2677 self.assertRaises(FeatureError, result.set, Foo.title > u"Title 40")2676 self.assertRaises(FeatureError, result.set, Foo.title > "Title 40")
26782677
2679 def test_find_set_expr_unsupported_without_column(self):2678 def test_find_set_expr_unsupported_without_column(self):
2680 result = self.store.find(Foo, title=u"Title 20")2679 result = self.store.find(Foo, title="Title 20")
2681 self.assertRaises(FeatureError, result.set,2680 self.assertRaises(FeatureError, result.set,
2682 Eq(object(), IntVariable(1)))2681 Eq(object(), IntVariable(1)))
26832682
2684 def test_find_set_expr_unsupported_without_expr_or_variable(self):2683 def test_find_set_expr_unsupported_without_expr_or_variable(self):
2685 result = self.store.find(Foo, title=u"Title 20")2684 result = self.store.find(Foo, title="Title 20")
2686 self.assertRaises(FeatureError, result.set, Eq(Foo.id, object()))2685 self.assertRaises(FeatureError, result.set, Eq(Foo.id, object()))
26872686
2688 def test_find_set_expr_unsupported_autoreloads(self):2687 def test_find_set_expr_unsupported_autoreloads(self):
2689 bar1 = self.store.get(Bar, 200)2688 bar1 = self.store.get(Bar, 200)
2690 bar2 = self.store.get(Bar, 300)2689 bar2 = self.store.get(Bar, 300)
2691 self.store.find(Bar, id=Select(SQL("200"))).set(title=u"Title 400")2690 self.store.find(Bar, id=Select(SQL("200"))).set(title="Title 400")
2692 bar1_vars = get_obj_info(bar1).variables2691 bar1_vars = get_obj_info(bar1).variables
2693 bar2_vars = get_obj_info(bar2).variables2692 bar2_vars = get_obj_info(bar2).variables
2694 self.assertEqual(bar1_vars[Bar.title].get_lazy(), AutoReload)2693 self.assertEqual(bar1_vars[Bar.title].get_lazy(), AutoReload)
@@ -2707,7 +2706,7 @@
2707 # column. See Bug #328603 for more info.2706 # column. See Bug #328603 for more info.
2708 foo1 = self.store.get(Foo, 20)2707 foo1 = self.store.get(Foo, 20)
2709 bar1 = self.store.get(Bar, 200)2708 bar1 = self.store.get(Bar, 200)
2710 self.store.find(Bar, id=Select(SQL("200"))).set(title=u"Title 400")2709 self.store.find(Bar, id=Select(SQL("200"))).set(title="Title 400")
2711 foo1_vars = get_obj_info(foo1).variables2710 foo1_vars = get_obj_info(foo1).variables
2712 bar1_vars = get_obj_info(bar1).variables2711 bar1_vars = get_obj_info(bar1).variables
2713 self.assertNotEqual(foo1_vars[Foo.title].get_lazy(), AutoReload)2712 self.assertNotEqual(foo1_vars[Foo.title].get_lazy(), AutoReload)
@@ -2741,7 +2740,7 @@
27412740
2742 def test_wb_find_set_checkpoints(self):2741 def test_wb_find_set_checkpoints(self):
2743 bar = self.store.get(Bar, 200)2742 bar = self.store.get(Bar, 200)
2744 self.store.find(Bar, id=200).set(title=u"Title 400")2743 self.store.find(Bar, id=200).set(title="Title 400")
2745 self.store._connection.execute("UPDATE bar SET "2744 self.store._connection.execute("UPDATE bar SET "
2746 "title='Title 500' "2745 "title='Title 500' "
2747 "WHERE id=200")2746 "WHERE id=200")
@@ -2759,7 +2758,7 @@
2759 obj_info = get_obj_info(foo)2758 obj_info = get_obj_info(foo)
2760 del foo2759 del foo
2761 gc.collect()2760 gc.collect()
2762 self.store.find(Foo, title=u"Title 20").set(title=u"Title 40")2761 self.store.find(Foo, title="Title 20").set(title="Title 40")
2763 foo = self.store.get(Foo, 20)2762 foo = self.store.get(Foo, 20)
2764 self.assertFalse(hasattr(foo, "tainted"))2763 self.assertFalse(hasattr(foo, "tainted"))
2765 self.assertEqual(foo.title, "Title 40")2764 self.assertEqual(foo.title, "Title 40")
@@ -2799,7 +2798,7 @@
2799 """2798 """
2800 self.get_cache(self.store).set_size(0)2799 self.get_cache(self.store).set_size(0)
2801 bar = self.store.get(Bar, 100)2800 bar = self.store.get(Bar, 100)
2802 bar.foo.title = u"Changed title"2801 bar.foo.title = "Changed title"
2803 bar_ref = weakref.ref(get_obj_info(bar))2802 bar_ref = weakref.ref(get_obj_info(bar))
2804 foo = bar.foo2803 foo = bar.foo
2805 del bar2804 del bar
@@ -2817,7 +2816,7 @@
2817 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)2816 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)
28182817
2819 foo = self.store.get(MyFoo, 10)2818 foo = self.store.get(MyFoo, 10)
2820 foo.bar.title = u"Changed title"2819 foo.bar.title = "Changed title"
2821 foo_ref = weakref.ref(get_obj_info(foo))2820 foo_ref = weakref.ref(get_obj_info(foo))
2822 bar = foo.bar2821 bar = foo.bar
2823 del foo2822 del foo
@@ -2830,13 +2829,13 @@
2830 pass2829 pass
2831 MyBar.foo = Reference(MyBar.title, Foo.title)2830 MyBar.foo = Reference(MyBar.title, Foo.title)
2832 bar = self.store.get(MyBar, 100)2831 bar = self.store.get(MyBar, 100)
2833 bar.title = u"Title 30"2832 bar.title = "Title 30"
2834 self.store.flush()2833 self.store.flush()
2835 self.assertEqual(bar.foo.id, 10)2834 self.assertEqual(bar.foo.id, 10)
2836 bar.foo.title = SQL("'Title 40'")2835 bar.foo.title = SQL("'Title 40'")
2837 self.assertEqual(bar.foo, None)2836 self.assertEqual(bar.foo, None)
2838 self.assertEqual(self.store.find(Foo, title=u"Title 30").one(), None)2837 self.assertEqual(self.store.find(Foo, title="Title 30").one(), None)
2839 self.assertEqual(self.store.get(Foo, 10).title, u"Title 40")2838 self.assertEqual(self.store.get(Foo, 10).title, "Title 40")
28402839
2841 def test_reference_on_non_primary_key(self):2840 def test_reference_on_non_primary_key(self):
2842 self.store.execute("INSERT INTO bar VALUES (400, 40, 'Title 30')")2841 self.store.execute("INSERT INTO bar VALUES (400, 40, 'Title 30')")
@@ -2856,7 +2855,7 @@
2856 def test_new_reference(self):2855 def test_new_reference(self):
2857 bar = Bar()2856 bar = Bar()
2858 bar.id = 4002857 bar.id = 400
2859 bar.title = u"Title 400"2858 bar.title = "Title 400"
2860 bar.foo_id = 102859 bar.foo_id = 10
28612860
2862 self.assertEqual(bar.foo, None)2861 self.assertEqual(bar.foo, None)
@@ -2895,12 +2894,12 @@
28952894
2896 def test_reference_on_added(self):2895 def test_reference_on_added(self):
2897 foo = Foo()2896 foo = Foo()
2898 foo.title = u"Title 40"2897 foo.title = "Title 40"
2899 self.store.add(foo)2898 self.store.add(foo)
29002899
2901 bar = Bar()2900 bar = Bar()
2902 bar.id = 4002901 bar.id = 400
2903 bar.title = u"Title 400"2902 bar.title = "Title 400"
2904 bar.foo = foo2903 bar.foo = foo
2905 self.store.add(bar)2904 self.store.add(bar)
29062905
@@ -2920,12 +2919,12 @@
29202919
2921 def test_reference_on_added_with_autoreload_key(self):2920 def test_reference_on_added_with_autoreload_key(self):
2922 foo = Foo()2921 foo = Foo()
2923 foo.title = u"Title 40"2922 foo.title = "Title 40"
2924 self.store.add(foo)2923 self.store.add(foo)
29252924
2926 bar = Bar()2925 bar = Bar()
2927 bar.id = 4002926 bar.id = 400
2928 bar.title = u"Title 400"2927 bar.title = "Title 400"
2929 bar.foo = foo2928 bar.foo = foo
2930 self.store.add(bar)2929 self.store.add(bar)
29312930
@@ -2952,11 +2951,11 @@
29522951
2953 def test_reference_assign_none(self):2952 def test_reference_assign_none(self):
2954 foo = Foo()2953 foo = Foo()
2955 foo.title = u"Title 40"2954 foo.title = "Title 40"
29562955
2957 bar = Bar()2956 bar = Bar()
2958 bar.id = 4002957 bar.id = 400
2959 bar.title = u"Title 400"2958 bar.title = "Title 400"
2960 bar.foo = foo2959 bar.foo = foo
2961 bar.foo = None2960 bar.foo = None
2962 bar.foo = None # Twice to make sure it doesn't blow up.2961 bar.foo = None # Twice to make sure it doesn't blow up.
@@ -2973,7 +2972,7 @@
2973 self.assertEqual(bar.foo, None)2972 self.assertEqual(bar.foo, None)
29742973
2975 def test_reference_on_added_composed_key(self):2974 def test_reference_on_added_composed_key(self):
2976 class Bar(object):2975 class Bar:
2977 __storm_table__ = "bar"2976 __storm_table__ = "bar"
2978 id = Int(primary=True)2977 id = Int(primary=True)
2979 foo_id = Int()2978 foo_id = Int()
@@ -2981,7 +2980,7 @@
2981 foo = Reference((foo_id, title), (Foo.id, Foo.title))2980 foo = Reference((foo_id, title), (Foo.id, Foo.title))
29822981
2983 foo = Foo()2982 foo = Foo()
2984 foo.title = u"Title 40"2983 foo.title = "Title 40"
2985 self.store.add(foo)2984 self.store.add(foo)
29862985
2987 bar = Bar()2986 bar = Bar()
@@ -3004,7 +3003,7 @@
3004 self.assertEqual(result.get_one(), ("Title 40",))3003 self.assertEqual(result.get_one(), ("Title 40",))
30053004
3006 def test_reference_assign_composed_remote_key(self):3005 def test_reference_assign_composed_remote_key(self):
3007 class Bar(object):3006 class Bar:
3008 __storm_table__ = "bar"3007 __storm_table__ = "bar"
3009 id = Int(primary=True)3008 id = Int(primary=True)
3010 foo_id = Int()3009 foo_id = Int()
@@ -3013,7 +3012,7 @@
30133012
3014 bar = Bar()3013 bar = Bar()
3015 bar.id = 4003014 bar.id = 400
3016 bar.foo = (20, u"Title 20")3015 bar.foo = (20, "Title 20")
3017 self.store.add(bar)3016 self.store.add(bar)
30183017
3019 self.assertEqual(bar.foo_id, 20)3018 self.assertEqual(bar.foo_id, 20)
@@ -3023,13 +3022,13 @@
30233022
3024 def test_reference_on_added_unlink_on_flush(self):3023 def test_reference_on_added_unlink_on_flush(self):
3025 foo = Foo()3024 foo = Foo()
3026 foo.title = u"Title 40"3025 foo.title = "Title 40"
3027 self.store.add(foo)3026 self.store.add(foo)
30283027
3029 bar = Bar()3028 bar = Bar()
3030 bar.id = 4003029 bar.id = 400
3031 bar.foo = foo3030 bar.foo = foo
3032 bar.title = u"Title 400"3031 bar.title = "Title 400"
3033 self.store.add(bar)3032 self.store.add(bar)
30343033
3035 foo.id = 403034 foo.id = 40
@@ -3057,15 +3056,15 @@
30573056
3058 def test_reference_on_two_added(self):3057 def test_reference_on_two_added(self):
3059 foo1 = Foo()3058 foo1 = Foo()
3060 foo1.title = u"Title 40"3059 foo1.title = "Title 40"
3061 foo2 = Foo()3060 foo2 = Foo()
3062 foo2.title = u"Title 40"3061 foo2.title = "Title 40"
3063 self.store.add(foo1)3062 self.store.add(foo1)
3064 self.store.add(foo2)3063 self.store.add(foo2)
30653064
3066 bar = Bar()3065 bar = Bar()
3067 bar.id = 4003066 bar.id = 400
3068 bar.title = u"Title 400"3067 bar.title = "Title 400"
3069 bar.foo = foo13068 bar.foo = foo1
3070 bar.foo = foo23069 bar.foo = foo2
3071 self.store.add(bar)3070 self.store.add(bar)
@@ -3077,12 +3076,12 @@
30773076
3078 def test_reference_on_added_and_changed_manually(self):3077 def test_reference_on_added_and_changed_manually(self):
3079 foo = Foo()3078 foo = Foo()
3080 foo.title = u"Title 40"3079 foo.title = "Title 40"
3081 self.store.add(foo)3080 self.store.add(foo)
30823081
3083 bar = Bar()3082 bar = Bar()
3084 bar.id = 4003083 bar.id = 400
3085 bar.title = u"Title 400"3084 bar.title = "Title 400"
3086 bar.foo = foo3085 bar.foo = foo
3087 self.store.add(bar)3086 self.store.add(bar)
30883087
@@ -3091,7 +3090,7 @@
3091 self.assertEqual(bar.foo_id, 40)3090 self.assertEqual(bar.foo_id, 40)
30923091
3093 def test_reference_on_added_composed_key_changed_manually(self):3092 def test_reference_on_added_composed_key_changed_manually(self):
3094 class Bar(object):3093 class Bar:
3095 __storm_table__ = "bar"3094 __storm_table__ = "bar"
3096 id = Int(primary=True)3095 id = Int(primary=True)
3097 foo_id = Int()3096 foo_id = Int()
@@ -3099,7 +3098,7 @@
3099 foo = Reference((foo_id, title), (Foo.id, Foo.title))3098 foo = Reference((foo_id, title), (Foo.id, Foo.title))
31003099
3101 foo = Foo()3100 foo = Foo()
3102 foo.title = u"Title 40"3101 foo.title = "Title 40"
3103 self.store.add(foo)3102 self.store.add(foo)
31043103
3105 bar = Bar()3104 bar = Bar()
@@ -3107,7 +3106,7 @@
3107 bar.foo = foo3106 bar.foo = foo
3108 self.store.add(bar)3107 self.store.add(bar)
31093108
3110 bar.title = u"Title 50"3109 bar.title = "Title 50"
31113110
3112 self.assertEqual(bar.foo, None)3111 self.assertEqual(bar.foo, None)
31133112
@@ -3117,12 +3116,12 @@
31173116
3118 def test_reference_on_added_no_local_store(self):3117 def test_reference_on_added_no_local_store(self):
3119 foo = Foo()3118 foo = Foo()
3120 foo.title = u"Title 40"3119 foo.title = "Title 40"
3121 self.store.add(foo)3120 self.store.add(foo)
31223121
3123 bar = Bar()3122 bar = Bar()
3124 bar.id = 4003123 bar.id = 400
3125 bar.title = u"Title 400"3124 bar.title = "Title 400"
3126 bar.foo = foo3125 bar.foo = foo
31273126
3128 self.assertEqual(Store.of(bar), self.store)3127 self.assertEqual(Store.of(bar), self.store)
@@ -3130,11 +3129,11 @@
31303129
3131 def test_reference_on_added_no_remote_store(self):3130 def test_reference_on_added_no_remote_store(self):
3132 foo = Foo()3131 foo = Foo()
3133 foo.title = u"Title 40"3132 foo.title = "Title 40"
31343133
3135 bar = Bar()3134 bar = Bar()
3136 bar.id = 4003135 bar.id = 400
3137 bar.title = u"Title 400"3136 bar.title = "Title 400"
3138 self.store.add(bar)3137 self.store.add(bar)
31393138
3140 bar.foo = foo3139 bar.foo = foo
@@ -3144,11 +3143,11 @@
31443143
3145 def test_reference_on_added_no_store(self):3144 def test_reference_on_added_no_store(self):
3146 foo = Foo()3145 foo = Foo()
3147 foo.title = u"Title 40"3146 foo.title = "Title 40"
31483147
3149 bar = Bar()3148 bar = Bar()
3150 bar.id = 4003149 bar.id = 400
3151 bar.title = u"Title 400"3150 bar.title = "Title 400"
3152 bar.foo = foo3151 bar.foo = foo
31533152
3154 self.store.add(bar)3153 self.store.add(bar)
@@ -3162,11 +3161,11 @@
31623161
3163 def test_reference_on_added_no_store_2(self):3162 def test_reference_on_added_no_store_2(self):
3164 foo = Foo()3163 foo = Foo()
3165 foo.title = u"Title 40"3164 foo.title = "Title 40"
31663165
3167 bar = Bar()3166 bar = Bar()
3168 bar.id = 4003167 bar.id = 400
3169 bar.title = u"Title 400"3168 bar.title = "Title 400"
3170 bar.foo = foo3169 bar.foo = foo
31713170
3172 self.store.add(foo)3171 self.store.add(foo)
@@ -3182,23 +3181,23 @@
3182 store = self.create_store()3181 store = self.create_store()
31833182
3184 foo = Foo()3183 foo = Foo()
3185 foo.title = u"Title 40"3184 foo.title = "Title 40"
3186 store.add(foo)3185 store.add(foo)
31873186
3188 bar = Bar()3187 bar = Bar()
3189 bar.id = 4003188 bar.id = 400
3190 bar.title = u"Title 400"3189 bar.title = "Title 400"
3191 self.store.add(bar)3190 self.store.add(bar)
31923191
3193 self.assertRaises(WrongStoreError, setattr, bar, "foo", foo)3192 self.assertRaises(WrongStoreError, setattr, bar, "foo", foo)
31943193
3195 def test_reference_on_added_no_store_unlink_before_adding(self):3194 def test_reference_on_added_no_store_unlink_before_adding(self):
3196 foo1 = Foo()3195 foo1 = Foo()
3197 foo1.title = u"Title 40"3196 foo1.title = "Title 40"
31983197
3199 bar = Bar()3198 bar = Bar()
3200 bar.id = 4003199 bar.id = 400
3201 bar.title = u"Title 400"3200 bar.title = "Title 400"
3202 bar.foo = foo13201 bar.foo = foo1
3203 bar.foo = None3202 bar.foo = None
32043203
@@ -3287,7 +3286,7 @@
3287 def test_reference_self(self):3286 def test_reference_self(self):
3288 selfref = self.store.add(SelfRef())3287 selfref = self.store.add(SelfRef())
3289 selfref.id = 4003288 selfref.id = 400
3290 selfref.title = u"Title 400"3289 selfref.title = "Title 400"
3291 selfref.selfref_id = 253290 selfref.selfref_id = 25
3292 self.assertEqual(selfref.selfref.id, 25)3291 self.assertEqual(selfref.selfref.id, 25)
3293 self.assertEqual(selfref.selfref.title, "SelfRef 25")3292 self.assertEqual(selfref.selfref.title, "SelfRef 25")
@@ -3300,7 +3299,7 @@
3300 def test_reference_wont_touch_store_when_key_is_none(self):3299 def test_reference_wont_touch_store_when_key_is_none(self):
3301 bar = self.store.get(Bar, 200)3300 bar = self.store.get(Bar, 200)
3302 bar.foo_id = None3301 bar.foo_id = None
3303 bar.title = u"Don't flush this!"3302 bar.title = "Don't flush this!"
33043303
3305 self.assertEqual(bar.foo, None)3304 self.assertEqual(bar.foo, None)
33063305
@@ -3310,7 +3309,7 @@
3310 def test_reference_wont_touch_store_when_key_is_unset(self):3309 def test_reference_wont_touch_store_when_key_is_unset(self):
3311 bar = self.store.get(Bar, 200)3310 bar = self.store.get(Bar, 200)
3312 del bar.foo_id3311 del bar.foo_id
3313 bar.title = u"Don't flush this!"3312 bar.title = "Don't flush this!"
33143313
3315 self.assertEqual(bar.foo, None)3314 self.assertEqual(bar.foo, None)
33163315
@@ -3320,7 +3319,7 @@
3320 self.assertEqual(result.get_one()[0], "Title 200")3319 self.assertEqual(result.get_one()[0], "Title 200")
33213320
3322 def test_reference_wont_touch_store_with_composed_key_none(self):3321 def test_reference_wont_touch_store_with_composed_key_none(self):
3323 class Bar(object):3322 class Bar:
3324 __storm_table__ = "bar"3323 __storm_table__ = "bar"
3325 id = Int(primary=True)3324 id = Int(primary=True)
3326 foo_id = Int()3325 foo_id = Int()
@@ -3354,12 +3353,12 @@
3354 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)3353 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)
33553354
3356 bar = Bar()3355 bar = Bar()
3357 bar.title = u"Title 400"3356 bar.title = "Title 400"
3358 self.store.add(bar)3357 self.store.add(bar)
33593358
3360 foo = MyFoo()3359 foo = MyFoo()
3361 foo.bar = bar3360 foo.bar = bar
3362 foo.title = u"Title 40"3361 foo.title = "Title 40"
3363 self.store.add(foo)3362 self.store.add(foo)
33643363
3365 self.store.flush()3364 self.store.flush()
@@ -3378,12 +3377,12 @@
3378 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)3377 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)
33793378
3380 bar = Bar()3379 bar = Bar()
3381 bar.title = u"Title 400"3380 bar.title = "Title 400"
3382 self.store.add(bar)3381 self.store.add(bar)
33833382
3384 foo = MyFoo()3383 foo = MyFoo()
3385 foo.bar = bar3384 foo.bar = bar
3386 foo.title = u"Title 40"3385 foo.title = "Title 40"
3387 self.store.add(foo)3386 self.store.add(foo)
33883387
3389 foo.id = 403388 foo.id = 40
@@ -3437,11 +3436,11 @@
3437 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)3436 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)
34383437
3439 bar = Bar()3438 bar = Bar()
3440 bar.title = u"Title 400"3439 bar.title = "Title 400"
34413440
3442 foo = MyFoo()3441 foo = MyFoo()
3443 foo.bar = bar3442 foo.bar = bar
3444 foo.title = u"Title 40"3443 foo.title = "Title 40"
34453444
3446 self.store.add(bar)3445 self.store.add(bar)
34473446
@@ -3457,11 +3456,11 @@
3457 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)3456 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)
34583457
3459 bar = Bar()3458 bar = Bar()
3460 bar.title = u"Title 400"3459 bar.title = "Title 400"
34613460
3462 foo = MyFoo()3461 foo = MyFoo()
3463 foo.bar = bar3462 foo.bar = bar
3464 foo.title = u"Title 40"3463 foo.title = "Title 40"
34653464
3466 self.store.add(foo)3465 self.store.add(foo)
34673466
@@ -3477,10 +3476,10 @@
3477 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)3476 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)
34783477
3479 bar = Bar()3478 bar = Bar()
3480 bar.title = u"Title 400"3479 bar.title = "Title 400"
34813480
3482 foo = MyFoo()3481 foo = MyFoo()
3483 foo.title = u"Title 40"3482 foo.title = "Title 40"
3484 foo.bar = bar3483 foo.bar = bar
34853484
3486 self.store.add(foo)3485 self.store.add(foo)
@@ -3495,10 +3494,10 @@
3495 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)3494 bar = Reference(Foo.id, Bar.foo_id, on_remote=True)
34963495
3497 bar = Bar()3496 bar = Bar()
3498 bar.title = u"Title 400"3497 bar.title = "Title 400"
34993498
3500 foo = MyFoo()3499 foo = MyFoo()
3501 foo.title = u"Title 40"3500 foo.title = "Title 40"
3502 foo.bar = bar3501 foo.bar = bar
35033502
3504 self.store.add(foo)3503 self.store.add(foo)
@@ -3673,7 +3672,7 @@
3673 bar = Bar()3672 bar = Bar()
3674 bar.id = 4003673 bar.id = 400
3675 bar.foo_id = 203674 bar.foo_id = 20
3676 bar.title = u"Title 100"3675 bar.title = "Title 100"
3677 self.store.add(bar)3676 self.store.add(bar)
36783677
3679 def test_reference_set(self):3678 def test_reference_set(self):
@@ -3718,13 +3717,13 @@
3718 def test_reference_set_with_added(self):3717 def test_reference_set_with_added(self):
3719 bar1 = Bar()3718 bar1 = Bar()
3720 bar1.id = 4003719 bar1.id = 400
3721 bar1.title = u"Title 400"3720 bar1.title = "Title 400"
3722 bar2 = Bar()3721 bar2 = Bar()
3723 bar2.id = 5003722 bar2.id = 500
3724 bar2.title = u"Title 500"3723 bar2.title = "Title 500"
37253724
3726 foo = FooRefSet()3725 foo = FooRefSet()
3727 foo.title = u"Title 40"3726 foo.title = "Title 40"
3728 foo.bars.add(bar1)3727 foo.bars.add(bar1)
3729 foo.bars.add(bar2)3728 foo.bars.add(bar2)
37303729
@@ -3743,7 +3742,7 @@
3743 self.add_reference_set_bar_400()3742 self.add_reference_set_bar_400()
37443743
3745 bar = self.store.get(Bar, 400)3744 bar = self.store.get(Bar, 400)
3746 bar.title = u"Title 20"3745 bar.title = "Title 20"
37473746
3748 class FooRefSetComposed(Foo):3747 class FooRefSetComposed(Foo):
3749 bars = ReferenceSet((Foo.id, Foo.title),3748 bars = ReferenceSet((Foo.id, Foo.title),
@@ -3760,7 +3759,7 @@
3760 ])3759 ])
37613760
3762 bar = self.store.get(Bar, 200)3761 bar = self.store.get(Bar, 200)
3763 bar.title = u"Title 20"3762 bar.title = "Title 20"
37643763
3765 del items[:]3764 del items[:]
3766 for bar in foo.bars:3765 for bar in foo.bars:
@@ -3803,11 +3802,11 @@
3803 # Notice that there's another item with this title in the base,3802 # Notice that there's another item with this title in the base,
3804 # which isn't part of the reference.3803 # which isn't part of the reference.
38053804
3806 objects = list(foo.bars.find(Bar.title == u"Title 100"))3805 objects = list(foo.bars.find(Bar.title == "Title 100"))
3807 self.assertEqual(len(objects), 1)3806 self.assertEqual(len(objects), 1)
3808 self.assertTrue(objects[0] is bar)3807 self.assertTrue(objects[0] is bar)
38093808
3810 objects = list(foo.bars.find(title=u"Title 100"))3809 objects = list(foo.bars.find(title="Title 100"))
3811 self.assertEqual(len(objects), 1)3810 self.assertEqual(len(objects), 1)
3812 self.assertTrue(objects[0] is bar)3811 self.assertTrue(objects[0] is bar)
38133812
@@ -4048,7 +4047,7 @@
4048 def test_reference_set_add(self):4047 def test_reference_set_add(self):
4049 bar = Bar()4048 bar = Bar()
4050 bar.id = 4004049 bar.id = 400
4051 bar.title = u"Title 100"4050 bar.title = "Title 100"
40524051
4053 foo = self.store.get(FooRefSet, 20)4052 foo = self.store.get(FooRefSet, 20)
4054 foo.bars.add(bar)4053 foo.bars.add(bar)
@@ -4059,10 +4058,10 @@
4059 def test_reference_set_add_no_store(self):4058 def test_reference_set_add_no_store(self):
4060 bar = Bar()4059 bar = Bar()
4061 bar.id = 4004060 bar.id = 400
4062 bar.title = u"Title 400"4061 bar.title = "Title 400"
40634062
4064 foo = FooRefSet()4063 foo = FooRefSet()
4065 foo.title = u"Title 40"4064 foo.title = "Title 40"
4066 foo.bars.add(bar)4065 foo.bars.add(bar)
40674066
4068 self.store.add(foo)4067 self.store.add(foo)
@@ -4077,10 +4076,10 @@
4077 def test_reference_set_add_no_store_2(self):4076 def test_reference_set_add_no_store_2(self):
4078 bar = Bar()4077 bar = Bar()
4079 bar.id = 4004078 bar.id = 400
4080 bar.title = u"Title 400"4079 bar.title = "Title 400"
40814080
4082 foo = FooRefSet()4081 foo = FooRefSet()
4083 foo.title = u"Title 40"4082 foo.title = "Title 40"
4084 foo.bars.add(bar)4083 foo.bars.add(bar)
40854084
4086 self.store.add(bar)4085 self.store.add(bar)
@@ -4095,13 +4094,13 @@
4095 def test_reference_set_add_no_store_unlink_after_adding(self):4094 def test_reference_set_add_no_store_unlink_after_adding(self):
4096 bar1 = Bar()4095 bar1 = Bar()
4097 bar1.id = 4004096 bar1.id = 400
4098 bar1.title = u"Title 400"4097 bar1.title = "Title 400"
4099 bar2 = Bar()4098 bar2 = Bar()
4100 bar2.id = 5004099 bar2.id = 500
4101 bar2.title = u"Title 500"4100 bar2.title = "Title 500"
41024101
4103 foo = FooRefSet()4102 foo = FooRefSet()
4104 foo.title = u"Title 40"4103 foo.title = "Title 40"
4105 foo.bars.add(bar1)4104 foo.bars.add(bar1)
4106 foo.bars.add(bar2)4105 foo.bars.add(bar2)
4107 foo.bars.remove(bar1)4106 foo.bars.remove(bar1)
@@ -4152,15 +4151,15 @@
4152 def test_indirect_reference_set_with_added(self):4151 def test_indirect_reference_set_with_added(self):
4153 bar1 = Bar()4152 bar1 = Bar()
4154 bar1.id = 4004153 bar1.id = 400
4155 bar1.title = u"Title 400"4154 bar1.title = "Title 400"
4156 bar2 = Bar()4155 bar2 = Bar()
4157 bar2.id = 5004156 bar2.id = 500
4158 bar2.title = u"Title 500"4157 bar2.title = "Title 500"
4159 self.store.add(bar1)4158 self.store.add(bar1)
4160 self.store.add(bar2)4159 self.store.add(bar2)
41614160
4162 foo = FooIndRefSet()4161 foo = FooIndRefSet()
4163 foo.title = u"Title 40"4162 foo.title = "Title 40"
4164 foo.bars.add(bar1)4163 foo.bars.add(bar1)
4165 foo.bars.add(bar2)4164 foo.bars.add(bar2)
41664165
@@ -4181,7 +4180,7 @@
4181 foo = self.store.get(FooIndRefSet, 20)4180 foo = self.store.get(FooIndRefSet, 20)
41824181
4183 items = []4182 items = []
4184 for bar in foo.bars.find(Bar.title == u"Title 300"):4183 for bar in foo.bars.find(Bar.title == "Title 300"):
4185 items.append((bar.id, bar.title))4184 items.append((bar.id, bar.title))
4186 items.sort()4185 items.sort()
41874186
@@ -4454,10 +4453,10 @@
4454 foo.id = 404453 foo.id = 40
4455 bar1 = Bar()4454 bar1 = Bar()
4456 bar1.id = 4004455 bar1.id = 400
4457 bar1.title = u"Title 400"4456 bar1.title = "Title 400"
4458 bar2 = Bar()4457 bar2 = Bar()
4459 bar2.id = 5004458 bar2.id = 500
4460 bar2.title = u"Title 500"4459 bar2.title = "Title 500"
4461 self.store.add(foo)4460 self.store.add(foo)
4462 self.store.add(bar1)4461 self.store.add(bar1)
4463 self.store.add(bar2)4462 self.store.add(bar2)
@@ -4478,13 +4477,13 @@
4478 def test_indirect_reference_set_with_added_no_store(self):4477 def test_indirect_reference_set_with_added_no_store(self):
4479 bar1 = Bar()4478 bar1 = Bar()
4480 bar1.id = 4004479 bar1.id = 400
4481 bar1.title = u"Title 400"4480 bar1.title = "Title 400"
4482 bar2 = Bar()4481 bar2 = Bar()
4483 bar2.id = 5004482 bar2.id = 500
4484 bar2.title = u"Title 500"4483 bar2.title = "Title 500"
44854484
4486 foo = FooIndRefSet()4485 foo = FooIndRefSet()
4487 foo.title = u"Title 40"4486 foo.title = "Title 40"
44884487
4489 foo.bars.add(bar1)4488 foo.bars.add(bar1)
4490 foo.bars.add(bar2)4489 foo.bars.add(bar2)
@@ -4629,7 +4628,7 @@
4629 foo5 = Foo()4628 foo5 = Foo()
46304629
4631 for i, foo in enumerate([foo1, foo2, foo3, foo4, foo5]):4630 for i, foo in enumerate([foo1, foo2, foo3, foo4, foo5]):
4632 foo.title = u"Object %d" % (i+1)4631 foo.title = "Object %d" % (i+1)
4633 self.store.add(foo)4632 self.store.add(foo)
46344633
4635 self.store.add_flush_order(foo2, foo4)4634 self.store.add_flush_order(foo2, foo4)
@@ -4660,7 +4659,7 @@
46604659
4661 def test_variable_filter_on_update(self):4660 def test_variable_filter_on_update(self):
4662 foo = self.store.get(FooVariable, 20)4661 foo = self.store.get(FooVariable, 20)
4663 foo.title = u"Title 20"4662 foo.title = "Title 20"
46644663
4665 self.store.flush()4664 self.store.flush()
46664665
@@ -4682,7 +4681,7 @@
4682 def test_variable_filter_on_insert(self):4681 def test_variable_filter_on_insert(self):
4683 foo = FooVariable()4682 foo = FooVariable()
4684 foo.id = 404683 foo.id = 40
4685 foo.title = u"Title 40"4684 foo.title = "Title 40"
46864685
4687 self.store.add(foo)4686 self.store.add(foo)
4688 self.store.flush()4687 self.store.flush()
@@ -4705,7 +4704,7 @@
47054704
4706 def test_variable_filter_on_set(self):4705 def test_variable_filter_on_set(self):
4707 foo = FooVariable()4706 foo = FooVariable()
4708 self.store.find(FooVariable, id=20).set(title=u"Title 20")4707 self.store.find(FooVariable, id=20).set(title="Title 20")
47094708
4710 self.assertEqual(self.get_items(), [4709 self.assertEqual(self.get_items(), [
4711 (10, "Title 30"),4710 (10, "Title 30"),
@@ -4716,7 +4715,7 @@
4716 def test_variable_filter_on_set_expr(self):4715 def test_variable_filter_on_set_expr(self):
4717 foo = FooVariable()4716 foo = FooVariable()
4718 result = self.store.find(FooVariable, id=20)4717 result = self.store.find(FooVariable, id=20)
4719 result.set(FooVariable.title == u"Title 20")4718 result.set(FooVariable.title == "Title 20")
47204719
4721 self.assertEqual(self.get_items(), [4720 self.assertEqual(self.get_items(), [
4722 (10, "Title 30"),4721 (10, "Title 30"),
@@ -4730,7 +4729,7 @@
4730 class MyResult(Result):4729 class MyResult(Result):
4731 def set_variable(self, variable, value):4730 def set_variable(self, variable, value):
4732 if variable.__class__ is UnicodeVariable:4731 if variable.__class__ is UnicodeVariable:
4733 variable.set(u"set_variable(%s)" % value)4732 variable.set("set_variable(%s)" % value)
4734 elif variable.__class__ is IntVariable:4733 elif variable.__class__ is IntVariable:
4735 variable.set(value+1)4734 variable.set(value+1)
4736 else:4735 else:
@@ -4747,7 +4746,7 @@
47474746
4748 def test_default(self):4747 def test_default(self):
4749 class MyFoo(Foo):4748 class MyFoo(Foo):
4750 title = Unicode(default=u"Some default value")4749 title = Unicode(default="Some default value")
47514750
4752 foo = MyFoo()4751 foo = MyFoo()
4753 self.store.add(foo)4752 self.store.add(foo)
@@ -4761,7 +4760,7 @@
47614760
4762 def test_default_factory(self):4761 def test_default_factory(self):
4763 class MyFoo(Foo):4762 class MyFoo(Foo):
4764 title = Unicode(default_factory=lambda:u"Some default value")4763 title = Unicode(default_factory=lambda:"Some default value")
47654764
4766 foo = MyFoo()4765 foo = MyFoo()
4767 self.store.add(foo)4766 self.store.add(foo)
@@ -4927,14 +4926,14 @@
4927 it is used to fill up any undefined variables.4926 it is used to fill up any undefined variables.
4928 """4927 """
4929 # We do a first find to get the object_infos into the cache.4928 # We do a first find to get the object_infos into the cache.
4930 foos = list(self.store.find(Foo, title=u"Title 20"))4929 foos = list(self.store.find(Foo, title="Title 20"))
49314930
4932 # Commit so that all foos are invalidated and variables are4931 # Commit so that all foos are invalidated and variables are
4933 # set back to AutoReload.4932 # set back to AutoReload.
4934 self.store.commit()4933 self.store.commit()
49354934
4936 # Another find which should reuse in-memory foos.4935 # Another find which should reuse in-memory foos.
4937 for foo in self.store.find(Foo, title=u"Title 20"):4936 for foo in self.store.find(Foo, title="Title 20"):
4938 # Make sure we have all variables defined, because4937 # Make sure we have all variables defined, because
4939 # values were already retrieved by the find's select.4938 # values were already retrieved by the find's select.
4940 obj_info = get_obj_info(foo)4939 obj_info = get_obj_info(foo)
@@ -4969,7 +4968,7 @@
4969 # set back to AutoReload.4968 # set back to AutoReload.
4970 self.store.commit()4969 self.store.commit()
49714970
4972 foo = self.store.find(MyFoo, title=u"Title 20").one()4971 foo = self.store.find(MyFoo, title="Title 20").one()
4973 self.assertEqual(foo.id, 20)4972 self.assertEqual(foo.id, 20)
4974 self.assertEqual(len(loaded), 2)4973 self.assertEqual(len(loaded), 2)
49754974
@@ -4982,7 +4981,7 @@
4982 """4981 """
4983 blob = self.store.get(Blob, 20)4982 blob = self.store.get(Blob, 20)
4984 blob.bin = b"\x80\x02}q\x01U\x01aK\x01s."4983 blob.bin = b"\x80\x02}q\x01U\x01aK\x01s."
4985 class PickleBlob(object):4984 class PickleBlob:
4986 __storm_table__ = "bin"4985 __storm_table__ = "bin"
4987 id = Int(primary=True)4986 id = Int(primary=True)
4988 pickle = Pickle("bin")4987 pickle = Pickle("bin")
@@ -5024,7 +5023,7 @@
50245023
5025 new_obj = DictFoo()5024 new_obj = DictFoo()
5026 new_obj.id = 405025 new_obj.id = 40
5027 new_obj.title = u"My Title"5026 new_obj.title = "My Title"
50285027
5029 self.store.add(new_obj)5028 self.store.add(new_obj)
5030 self.store.commit()5029 self.store.commit()
@@ -5122,7 +5121,7 @@
5122 self.assertTrue(lazy_value is AutoReload)5121 self.assertTrue(lazy_value is AutoReload)
51235122
5124 # Which gets resolved once touched.5123 # Which gets resolved once touched.
5125 self.assertEqual(foo.title, u"New title")5124 self.assertEqual(foo.title, "New title")
51265125
5127 def test_expr_values_flush_on_demand_with_added(self):5126 def test_expr_values_flush_on_demand_with_added(self):
5128 foo = Foo()5127 foo = Foo()
@@ -5353,7 +5352,7 @@
5353 foo = Foo()5352 foo = Foo()
5354 self.store.add(foo)5353 self.store.add(foo)
5355 foo.id = AutoReload5354 foo.id = AutoReload
5356 foo.title = u"New Title"5355 foo.title = "New Title"
5357 self.assertTrue(isinstance(foo.id, int))5356 self.assertTrue(isinstance(foo.id, int))
5358 self.assertEqual(foo.title, "New Title")5357 self.assertEqual(foo.title, "New Title")
53595358
@@ -5401,7 +5400,7 @@
5401 self.store.flush()5400 self.store.flush()
5402 lazy_value = get_obj_info(foo).variables[Foo.title].get_lazy()5401 lazy_value = get_obj_info(foo).variables[Foo.title].get_lazy()
5403 self.assertEqual(lazy_value, AutoReload)5402 self.assertEqual(lazy_value, AutoReload)
5404 self.assertEqual(foo.title, u"Default Title")5403 self.assertEqual(foo.title, "Default Title")
54055404
5406 def test_reference_break_on_local_diverged_doesnt_autoreload(self):5405 def test_reference_break_on_local_diverged_doesnt_autoreload(self):
5407 foo = self.store.get(Foo, 10)5406 foo = self.store.get(Foo, 10)
@@ -5422,7 +5421,7 @@
5422 committed, detecting if the referenced object has been removed behind5421 committed, detecting if the referenced object has been removed behind
5423 its back.5422 its back.
5424 """5423 """
5425 class BarOnRemote(object):5424 class BarOnRemote:
5426 __storm_table__ = "bar"5425 __storm_table__ = "bar"
5427 foo_id = Int(primary=True)5426 foo_id = Int(primary=True)
5428 foo = Reference(foo_id, Foo.id, on_remote=True)5427 foo = Reference(foo_id, Foo.id, on_remote=True)
@@ -5476,7 +5475,7 @@
5476 self.store.add(foo)5475 self.store.add(foo)
5477 self.store.invalidate(foo)5476 self.store.invalidate(foo)
5478 foo.id = 405477 foo.id = 40
5479 foo.title = u"Title 40"5478 foo.title = "Title 40"
5480 self.store.flush()5479 self.store.flush()
54815480
5482 # Object must have a valid cache at this point, since it was5481 # Object must have a valid cache at this point, since it was
@@ -5488,7 +5487,7 @@
5488 foo = self.store.get(Foo, 20)5487 foo = self.store.get(Foo, 20)
5489 self.store.execute("DELETE FROM foo WHERE id=20")5488 self.store.execute("DELETE FROM foo WHERE id=20")
5490 self.store.invalidate(foo)5489 self.store.invalidate(foo)
5491 self.assertRaises(LostObjectError, setattr, foo, "title", u"Title 40")5490 self.assertRaises(LostObjectError, setattr, foo, "title", "Title 40")
54925491
5493 def test_invalidated_objects_reloaded_by_get(self):5492 def test_invalidated_objects_reloaded_by_get(self):
5494 foo = self.store.get(Foo, 20)5493 foo = self.store.get(Foo, 20)
@@ -5496,7 +5495,7 @@
5496 foo = self.store.get(Foo, 20)5495 foo = self.store.get(Foo, 20)
5497 title_variable = get_obj_info(foo).variables[Foo.title]5496 title_variable = get_obj_info(foo).variables[Foo.title]
5498 self.assertEqual(title_variable.get_lazy(), None)5497 self.assertEqual(title_variable.get_lazy(), None)
5499 self.assertEqual(title_variable.get(), u"Title 20")5498 self.assertEqual(title_variable.get(), "Title 20")
5500 self.assertEqual(foo.title, "Title 20")5499 self.assertEqual(foo.title, "Title 20")
55015500
5502 def test_invalidated_hook(self):5501 def test_invalidated_hook(self):
@@ -5548,7 +5547,7 @@
5548 """5547 """
5549 foo1 = self.store.get(Foo, 10)5548 foo1 = self.store.get(Foo, 10)
5550 foo1_title = foo1.title5549 foo1_title = foo1.title
5551 foo1.title = u"radix wuz here"5550 foo1.title = "radix wuz here"
5552 self.store.reset()5551 self.store.reset()
5553 self.store.flush()5552 self.store.flush()
5554 new_foo1 = self.store.get(Foo, 10)5553 new_foo1 = self.store.get(Foo, 10)
@@ -5587,14 +5586,14 @@
5587 def test_result_find_introduce_join(self):5586 def test_result_find_introduce_join(self):
5588 result1 = self.store.find(Foo, Foo.id <= 20)5587 result1 = self.store.find(Foo, Foo.id <= 20)
5589 result2 = result1.find(Foo.id == Bar.foo_id,5588 result2 = result1.find(Foo.id == Bar.foo_id,
5590 Bar.title == u"Title 300")5589 Bar.title == "Title 300")
5591 foo = result2.one()5590 foo = result2.one()
5592 self.assertTrue(foo)5591 self.assertTrue(foo)
5593 self.assertEqual(foo.id, 10)5592 self.assertEqual(foo.id, 10)
55945593
5595 def test_result_find_tuple(self):5594 def test_result_find_tuple(self):
5596 result1 = self.store.find((Foo, Bar), Foo.id == Bar.foo_id)5595 result1 = self.store.find((Foo, Bar), Foo.id == Bar.foo_id)
5597 result2 = result1.find(Bar.title == u"Title 100")5596 result2 = result1.find(Bar.title == "Title 100")
5598 foo_bar = result2.one()5597 foo_bar = result2.one()
5599 self.assertTrue(foo_bar)5598 self.assertTrue(foo_bar)
5600 foo, bar = foo_bar5599 foo, bar = foo_bar
@@ -5694,7 +5693,7 @@
5694 result2 = self.store.find(Foo, id=10)5693 result2 = self.store.find(Foo, id=10)
5695 result3 = result1.union(result2)5694 result3 = result1.union(result2)
56965695
5697 self.assertRaises(FeatureError, result3.set, title=u"Title 40")5696 self.assertRaises(FeatureError, result3.set, title="Title 40")
5698 self.assertRaises(FeatureError, result3.remove)5697 self.assertRaises(FeatureError, result3.remove)
56995698
5700 def test_result_union_count(self):5699 def test_result_union_count(self):
@@ -5848,7 +5847,7 @@
5848 self.assertEqual(bar.foo_title, "Title 20")5847 self.assertEqual(bar.foo_title, "Title 20")
58495848
5850 def test_proxy_equals(self):5849 def test_proxy_equals(self):
5851 bar = self.store.find(BarProxy, BarProxy.foo_title == u"Title 20").one()5850 bar = self.store.find(BarProxy, BarProxy.foo_title == "Title 20").one()
5852 self.assertTrue(bar)5851 self.assertTrue(bar)
5853 self.assertEqual(bar.id, 200)5852 self.assertEqual(bar.id, 200)
58545853
@@ -5859,7 +5858,7 @@
58595858
5860 def test_proxy_set(self):5859 def test_proxy_set(self):
5861 bar = self.store.get(BarProxy, 200)5860 bar = self.store.get(BarProxy, 200)
5862 bar.foo_title = u"New Title"5861 bar.foo_title = "New Title"
5863 foo = self.store.get(Foo, 20)5862 foo = self.store.get(Foo, 20)
5864 self.assertEqual(foo.title, "New Title")5863 self.assertEqual(foo.title, "New Title")
58655864
@@ -5888,7 +5887,7 @@
58885887
5889 def test_proxy_with_string_variable_factory_attribute(self):5888 def test_proxy_with_string_variable_factory_attribute(self):
5890 MyBarProxy, MyFoo = self.get_bar_proxy_with_string()5889 MyBarProxy, MyFoo = self.get_bar_proxy_with_string()
5891 variable = MyBarProxy.foo_title.variable_factory(value=u"Hello")5890 variable = MyBarProxy.foo_title.variable_factory(value="Hello")
5892 self.assertTrue(isinstance(variable, UnicodeVariable))5891 self.assertTrue(isinstance(variable, UnicodeVariable))
58935892
5894 def test_proxy_with_extra_table(self):5893 def test_proxy_with_extra_table(self):
@@ -5897,13 +5896,13 @@
5897 more tables in the query.5896 more tables in the query.
5898 """5897 """
5899 result = self.store.find((BarProxy, Link),5898 result = self.store.find((BarProxy, Link),
5900 BarProxy.foo_title == u"Title 20",5899 BarProxy.foo_title == "Title 20",
5901 BarProxy.foo_id == Link.foo_id)5900 BarProxy.foo_id == Link.foo_id)
5902 results = list(result)5901 results = list(result)
5903 self.assertEqual(len(results), 2)5902 self.assertEqual(len(results), 2)
5904 for bar, link in results:5903 for bar, link in results:
5905 self.assertEqual(bar.id, 200)5904 self.assertEqual(bar.id, 200)
5906 self.assertEqual(bar.foo_title, u"Title 20")5905 self.assertEqual(bar.foo_title, "Title 20")
5907 self.assertEqual(bar.foo_id, 20)5906 self.assertEqual(bar.foo_id, 20)
5908 self.assertEqual(link.foo_id, 20)5907 self.assertEqual(link.foo_id, 20)
59095908
@@ -5942,7 +5941,7 @@
5942 check.append([column.name for column in primary_columns])5941 check.append([column.name for column in primary_columns])
5943 primary_variables[0].set(SQL("40"))5942 primary_variables[0].set(SQL("40"))
59445943
5945 class DatabaseWrapper(object):5944 class DatabaseWrapper:
5946 """Wrapper to inject our custom preset_primary_key hook."""5945 """Wrapper to inject our custom preset_primary_key hook."""
59475946
5948 def __init__(self, database):5947 def __init__(self, database):
@@ -6027,7 +6026,7 @@
6027 pass6026 pass
6028 foo = self.store.get(Foo, 20)6027 foo = self.store.get(Foo, 20)
6029 myfoo = self.store.get(MyFoo, 20)6028 myfoo = self.store.get(MyFoo, 20)
6030 for title in [u'Cừơng', u'Đức', u'Hạnh']:6029 for title in ['Cừơng', 'Đức', 'Hạnh']:
6031 foo.title = title6030 foo.title = title
6032 self.store.commit()6031 self.store.commit()
6033 try:6032 try:
@@ -6055,7 +6054,7 @@
60556054
6056 MyFoo.sequence = 06055 MyFoo.sequence = 0
6057 for foo in foos:6056 for foo in foos:
6058 foo.title = u"Changed Title"6057 foo.title = "Changed Title"
6059 self.store.flush()6058 self.store.flush()
60606059
6061 for i, foo in enumerate(foos):6060 for i, foo in enumerate(foos):
@@ -6089,16 +6088,16 @@
6089 """6088 """
6090 store = self.create_store()6089 store = self.create_store()
6091 foo2 = store.get(Foo, 10)6090 foo2 = store.get(Foo, 10)
6092 self.assertEqual(foo2.title, u"Title 30")6091 self.assertEqual(foo2.title, "Title 30")
6093 store.commit()6092 store.commit()
60946093
6095 foo1 = self.store.get(Foo, 10)6094 foo1 = self.store.get(Foo, 10)
6096 foo1.title = u"Title 40"6095 foo1.title = "Title 40"
6097 self.store.commit()6096 self.store.commit()
60986097
6099 foo2.title = u"Title 30"6098 foo2.title = "Title 30"
6100 store.commit()6099 store.commit()
6101 self.assertEqual(foo2.title, u"Title 30")6100 self.assertEqual(foo2.title, "Title 30")
61026101
6103 def test_execute_sends_event(self):6102 def test_execute_sends_event(self):
6104 """Statement execution emits the register-transaction event."""6103 """Statement execution emits the register-transaction event."""
@@ -6131,7 +6130,7 @@
6131 calls.append(owner)6130 calls.append(owner)
6132 self.store._event.hook("register-transaction", register_transaction)6131 self.store._event.hook("register-transaction", register_transaction)
6133 foo = Foo()6132 foo = Foo()
6134 foo.title = u"Foo"6133 foo.title = "Foo"
6135 self.store.add(foo)6134 self.store.add(foo)
6136 self.assertEqual(len(calls), 1)6135 self.assertEqual(len(calls), 1)
6137 self.assertEqual(calls[0], self.store)6136 self.assertEqual(calls[0], self.store)
@@ -6160,7 +6159,7 @@
6160 self.store.rollback()6159 self.store.rollback()
6161 del calls[:]6160 del calls[:]
61626161
6163 foo.title = u"New title"6162 foo.title = "New title"
6164 self.assertEqual(len(calls), 1)6163 self.assertEqual(len(calls), 1)
6165 self.assertEqual(calls[0], self.store)6164 self.assertEqual(calls[0], self.store)
61666165
@@ -6170,7 +6169,7 @@
6170 self.assertEqual(result_to_remove.remove(), 3)6169 self.assertEqual(result_to_remove.remove(), 3)
61716170
61726171
6173class EmptyResultSetTest(object):6172class EmptyResultSetTest:
61746173
6175 def setUp(self):6174 def setUp(self):
6176 self.create_database()6175 self.create_database()
@@ -6346,8 +6345,8 @@
6346 self.assertEqual(self.empty.cached(), [])6345 self.assertEqual(self.empty.cached(), [])
63476346
6348 def test_find(self):6347 def test_find(self):
6349 self.assertEqual(list(self.result.find(Foo.title == u"foo")), [])6348 self.assertEqual(list(self.result.find(Foo.title == "foo")), [])
6350 self.assertEqual(list(self.empty.find(Foo.title == u"foo")), [])6349 self.assertEqual(list(self.empty.find(Foo.title == "foo")), [])
63516350
6352 def test_union(self):6351 def test_union(self):
6353 self.assertEqual(self.empty.union(self.empty), self.empty)6352 self.assertEqual(self.empty.union(self.empty), self.empty)
63546353
=== modified file 'storm/tests/store/block.py'
--- storm/tests/store/block.py 2020-03-18 16:20:14 +0000
+++ storm/tests/store/block.py 2024-03-13 16:26:38 +0000
@@ -30,7 +30,7 @@
30 helpers = [MakePath]30 helpers = [MakePath]
3131
32 def setUp(self):32 def setUp(self):
33 super(BlockAccessTest, self).setUp()33 super().setUp()
34 database = SQLite(URI("sqlite:"))34 database = SQLite(URI("sqlite:"))
35 self.store = Store(database)35 self.store = Store(database)
3636
3737
=== modified file 'storm/tests/store/postgres.py'
--- storm/tests/store/postgres.py 2024-03-04 10:59:55 +0000
+++ storm/tests/store/postgres.py 2024-03-13 16:26:38 +0000
@@ -28,17 +28,17 @@
28from storm.tests.helper import TestHelper28from storm.tests.helper import TestHelper
2929
3030
31class Lst1(object):31class Lst1:
32 __storm_table__ = "lst1"32 __storm_table__ = "lst1"
33 id = Int(primary=True)33 id = Int(primary=True)
34 ints = List(type=Int())34 ints = List(type=Int())
3535
36class LstEnum(object):36class LstEnum:
37 __storm_table__ = "lst1"37 __storm_table__ = "lst1"
38 id = Int(primary=True)38 id = Int(primary=True)
39 ints = List(type=Enum(map={"one": 1, "two": 2, "three": 3}))39 ints = List(type=Enum(map={"one": 1, "two": 2, "three": 3}))
4040
41class Lst2(object):41class Lst2:
42 __storm_table__ = "lst2"42 __storm_table__ = "lst2"
43 id = Int(primary=True)43 id = Int(primary=True)
44 ints = List(type=List(type=Int()))44 ints = List(type=List(type=Int()))
@@ -170,7 +170,7 @@
170170
171 def test_add_find_with_schema(self):171 def test_add_find_with_schema(self):
172 foo = FooWithSchema()172 foo = FooWithSchema()
173 foo.title = u"Title"173 foo.title = "Title"
174 self.store.add(foo)174 self.store.add(foo)
175 self.store.flush()175 self.store.flush()
176 # We use find() here to actually exercise the backend code.176 # We use find() here to actually exercise the backend code.
177177
=== modified file 'storm/tests/tracer.py'
--- storm/tests/tracer.py 2024-03-04 10:59:55 +0000
+++ storm/tests/tracer.py 2024-03-13 16:26:38 +0000
@@ -32,7 +32,7 @@
32class TracerTest(TestHelper):32class TracerTest(TestHelper):
3333
34 def tearDown(self):34 def tearDown(self):
35 super(TracerTest, self).tearDown()35 super().tearDown()
36 del _tracers[:]36 del _tracers[:]
3737
38 def test_install_tracer(self):38 def test_install_tracer(self):
@@ -63,7 +63,7 @@
63 self.assertEqual(get_tracers(), [])63 self.assertEqual(get_tracers(), [])
6464
65 def test_remove_tracer_type(self):65 def test_remove_tracer_type(self):
66 class C(object):66 class C:
67 pass67 pass
6868
69 class D(C):69 class D(C):
@@ -100,7 +100,7 @@
100 def test_trace(self):100 def test_trace(self):
101 stash = []101 stash = []
102102
103 class Tracer(object):103 class Tracer:
104 def m1(_, *args, **kwargs):104 def m1(_, *args, **kwargs):
105 stash.extend(["m1", args, kwargs])105 stash.extend(["m1", args, kwargs])
106106
@@ -126,7 +126,7 @@
126class DebugTracerTest(TestHelper):126class DebugTracerTest(TestHelper):
127127
128 def setUp(self):128 def setUp(self):
129 super(DebugTracerTest, self).setUp()129 super().setUp()
130 self.stream = self.mocker.mock(type(sys.stderr))130 self.stream = self.mocker.mock(type(sys.stderr))
131 self.tracer = DebugTracer(self.stream)131 self.tracer = DebugTracer(self.stream)
132132
@@ -139,7 +139,7 @@
139139
140 def tearDown(self):140 def tearDown(self):
141 del _tracers[:]141 del _tracers[:]
142 super(DebugTracerTest, self).tearDown()142 super().tearDown()
143143
144 def test_wb_debug_tracer_uses_stderr_by_default(self):144 def test_wb_debug_tracer_uses_stderr_by_default(self):
145 self.mocker.replay()145 self.mocker.replay()
@@ -233,7 +233,7 @@
233 tracer_class = TimeoutTracer233 tracer_class = TimeoutTracer
234234
235 def setUp(self):235 def setUp(self):
236 super(TimeoutTracerTestBase, self).setUp()236 super().setUp()
237 self.tracer = self.tracer_class()237 self.tracer = self.tracer_class()
238 self.raw_cursor = self.mocker.mock()238 self.raw_cursor = self.mocker.mock()
239 self.statement = self.mocker.mock()239 self.statement = self.mocker.mock()
@@ -241,13 +241,13 @@
241241
242 # Some data is kept in the connection, so we use a proxy to242 # Some data is kept in the connection, so we use a proxy to
243 # allow things we don't care about here to happen.243 # allow things we don't care about here to happen.
244 class Connection(object):244 class Connection:
245 pass245 pass
246246
247 self.connection = self.mocker.proxy(Connection())247 self.connection = self.mocker.proxy(Connection())
248248
249 def tearDown(self):249 def tearDown(self):
250 super(TimeoutTracerTestBase, self).tearDown()250 super().tearDown()
251 del _tracers[:]251 del _tracers[:]
252252
253 def execute(self):253 def execute(self):
@@ -384,14 +384,14 @@
384class TimeoutTracerWithDBTest(TestHelper):384class TimeoutTracerWithDBTest(TestHelper):
385385
386 def setUp(self):386 def setUp(self):
387 super(TimeoutTracerWithDBTest, self).setUp()387 super().setUp()
388 self.tracer = StuckInTimeTimeoutTracer(10)388 self.tracer = StuckInTimeTimeoutTracer(10)
389 install_tracer(self.tracer)389 install_tracer(self.tracer)
390 database = create_database(os.environ["STORM_POSTGRES_URI"])390 database = create_database(os.environ["STORM_POSTGRES_URI"])
391 self.connection = database.connect()391 self.connection = database.connect()
392392
393 def tearDown(self):393 def tearDown(self):
394 super(TimeoutTracerWithDBTest, self).tearDown()394 super().tearDown()
395 remove_tracer(self.tracer)395 remove_tracer(self.tracer)
396 self.connection.close()396 self.connection.close()
397397
@@ -430,7 +430,7 @@
430class StuckInTimeTimeoutTracer(TimeoutTracer):430class StuckInTimeTimeoutTracer(TimeoutTracer):
431431
432 def __init__(self, fixed_remaining_time):432 def __init__(self, fixed_remaining_time):
433 super(StuckInTimeTimeoutTracer, self).__init__()433 super().__init__()
434 self.set_statement_timeout_calls = []434 self.set_statement_timeout_calls = []
435 self.fixed_remaining_time = fixed_remaining_time435 self.fixed_remaining_time = fixed_remaining_time
436436
@@ -467,7 +467,7 @@
467 tracer = self.LoggingBaseStatementTracer()467 tracer = self.LoggingBaseStatementTracer()
468 conn = StubConnection()468 conn = StubConnection()
469 conn.param_mark = '%s'469 conn.param_mark = '%s'
470 var1 = MockVariable(u'VAR1')470 var1 = MockVariable('VAR1')
471 tracer.connection_raw_execute(471 tracer.connection_raw_execute(
472 conn, 'cursor', 'SELECT * FROM person where name = %s', [var1])472 conn, 'cursor', 'SELECT * FROM person where name = %s', [var1])
473 self.assertEqual(473 self.assertEqual(
@@ -478,7 +478,7 @@
478 """String parameters are formatted as a single quoted string."""478 """String parameters are formatted as a single quoted string."""
479 tracer = self.LoggingBaseStatementTracer()479 tracer = self.LoggingBaseStatementTracer()
480 conn = StubConnection()480 conn = StubConnection()
481 var1 = MockVariable(u'VAR1')481 var1 = MockVariable('VAR1')
482 tracer.connection_raw_execute(482 tracer.connection_raw_execute(
483 conn, 'cursor', 'SELECT * FROM person where name = ?', [var1])483 conn, 'cursor', 'SELECT * FROM person where name = ?', [var1])
484 self.assertEqual(484 self.assertEqual(
@@ -513,7 +513,7 @@
513 """% operators in LIKE statements are preserved."""513 """% operators in LIKE statements are preserved."""
514 tracer = self.LoggingBaseStatementTracer()514 tracer = self.LoggingBaseStatementTracer()
515 conn = StubConnection()515 conn = StubConnection()
516 var1 = MockVariable(u'substring')516 var1 = MockVariable('substring')
517 tracer.connection_raw_execute(517 tracer.connection_raw_execute(
518 conn, 'cursor',518 conn, 'cursor',
519 "SELECT * FROM person WHERE name LIKE '%%' || ? || '-suffix%%'",519 "SELECT * FROM person WHERE name LIKE '%%' || ? || '-suffix%%'",
@@ -526,14 +526,14 @@
526 def test_unformattable_statements_are_handled(self):526 def test_unformattable_statements_are_handled(self):
527 tracer = self.LoggingBaseStatementTracer()527 tracer = self.LoggingBaseStatementTracer()
528 conn = StubConnection()528 conn = StubConnection()
529 var1 = MockVariable(u'substring')529 var1 = MockVariable('substring')
530 tracer.connection_raw_execute(530 tracer.connection_raw_execute(
531 conn, 'cursor', "%s %s",531 conn, 'cursor', "%s %s",
532 [var1])532 [var1])
533 self.assertEqual(533 self.assertEqual(
534 [(conn, 'cursor',534 [(conn, 'cursor',
535 "Unformattable query: '%%s %%s' with params [%r]." %535 "Unformattable query: '%%s %%s' with params [%r]." %
536 u'substring')],536 'substring')],
537 tracer.calls)537 tracer.calls)
538538
539539
@@ -605,7 +605,7 @@
605 return has_fixtures605 return has_fixtures
606606
607 def tearDown(self):607 def tearDown(self):
608 super(CaptureTracerTest, self).tearDown()608 super().tearDown()
609 del _tracers[:]609 del _tracers[:]
610610
611 def test_capture(self):611 def test_capture(self):
@@ -617,7 +617,7 @@
617 self.assertEqual([tracer], get_tracers())617 self.assertEqual([tracer], get_tracers())
618 conn = StubConnection()618 conn = StubConnection()
619 conn.param_mark = '%s'619 conn.param_mark = '%s'
620 var = MockVariable(u"var")620 var = MockVariable("var")
621 tracer.connection_raw_execute(conn, "cursor", "select %s", [var])621 tracer.connection_raw_execute(conn, "cursor", "select %s", [var])
622 self.assertEqual(["select 'var'"], tracer.queries)622 self.assertEqual(["select 'var'"], tracer.queries)
623623
624624
=== modified file 'storm/tests/variables.py'
--- storm/tests/variables.py 2024-03-04 10:59:55 +0000
+++ storm/tests/variables.py 2024-03-13 16:26:38 +0000
@@ -35,7 +35,7 @@
35from storm.tests.helper import TestHelper35from storm.tests.helper import TestHelper
3636
3737
38class Marker(object):38class Marker:
39 pass39 pass
4040
41marker = Marker()41marker = Marker()
@@ -461,15 +461,15 @@
461 self.assertEqual(variable.get(), b"str")461 self.assertEqual(variable.get(), b"str")
462 variable.set(memoryview(b"buffer"))462 variable.set(memoryview(b"buffer"))
463 self.assertEqual(variable.get(), b"buffer")463 self.assertEqual(variable.get(), b"buffer")
464 self.assertRaises(TypeError, variable.set, u"unicode")464 self.assertRaises(TypeError, variable.set, "unicode")
465465
466466
467class UnicodeVariableTest(TestHelper):467class UnicodeVariableTest(TestHelper):
468468
469 def test_set_get(self):469 def test_set_get(self):
470 variable = UnicodeVariable()470 variable = UnicodeVariable()
471 variable.set(u"unicode")471 variable.set("unicode")
472 self.assertEqual(variable.get(), u"unicode")472 self.assertEqual(variable.get(), "unicode")
473 self.assertRaises(TypeError, variable.set, b"str")473 self.assertRaises(TypeError, variable.set, b"str")
474474
475475
@@ -814,7 +814,7 @@
814 self.assertRaises(TypeError, variable.set,814 self.assertRaises(TypeError, variable.set,
815 "0609f76b-878f-4546-baf5-c1b135e8de72")815 "0609f76b-878f-4546-baf5-c1b135e8de72")
816 self.assertRaises(TypeError, variable.set,816 self.assertRaises(TypeError, variable.set,
817 u"0609f76b-878f-4546-baf5-c1b135e8de72")817 "0609f76b-878f-4546-baf5-c1b135e8de72")
818818
819 def test_get_set_from_database(self):819 def test_get_set_from_database(self):
820 value = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}")820 value = uuid.UUID("{0609f76b-878f-4546-baf5-c1b135e8de72}")
@@ -826,7 +826,7 @@
826 self.assertEqual(variable.get(), value)826 self.assertEqual(variable.get(), value)
827 variable.set("0609f76b-878f-4546-baf5-c1b135e8de72", from_db=True)827 variable.set("0609f76b-878f-4546-baf5-c1b135e8de72", from_db=True)
828 self.assertEqual(variable.get(), value)828 self.assertEqual(variable.get(), value)
829 variable.set(u"0609f76b-878f-4546-baf5-c1b135e8de72", from_db=True)829 variable.set("0609f76b-878f-4546-baf5-c1b135e8de72", from_db=True)
830 self.assertEqual(variable.get(), value)830 self.assertEqual(variable.get(), value)
831831
832 # Some other representations for UUID values.832 # Some other representations for UUID values.
@@ -836,7 +836,7 @@
836 self.assertEqual(variable.get(), value)836 self.assertEqual(variable.get(), value)
837837
838838
839class EncodedValueVariableTestMixin(object):839class EncodedValueVariableTestMixin:
840840
841 encoding = None841 encoding = None
842 variable_type = None842 variable_type = None
@@ -925,7 +925,7 @@
925 # JSONVariable._dumps() works around text/bytes handling issues in925 # JSONVariable._dumps() works around text/bytes handling issues in
926 # json.926 # json.
927 variable = self.variable_type()927 variable = self.variable_type()
928 variable.set({u"a": 1})928 variable.set({"a": 1})
929 self.assertTrue(isinstance(variable.get(to_db=True), str))929 self.assertTrue(isinstance(variable.get(to_db=True), str))
930930
931931
932932
=== modified file 'storm/tests/wsgi.py'
--- storm/tests/wsgi.py 2024-03-04 10:59:55 +0000
+++ storm/tests/wsgi.py 2024-03-13 16:26:38 +0000
@@ -105,7 +105,7 @@
105 self.assertEqual(timeline, found_timeline)105 self.assertEqual(timeline, found_timeline)
106106
107107
108class FakeTimeline(object):108class FakeTimeline:
109 """A fake Timeline.109 """A fake Timeline.
110110
111 We need this because we can't use plain object instances as they can't be111 We need this because we can't use plain object instances as they can't be
112112
=== modified file 'storm/tests/zope/adapters.py'
--- storm/tests/zope/adapters.py 2024-03-04 10:59:55 +0000
+++ storm/tests/zope/adapters.py 2024-03-13 16:26:38 +0000
@@ -31,7 +31,7 @@
31 from storm.zope.interfaces import IResultSet, ISQLObjectResultSet31 from storm.zope.interfaces import IResultSet, ISQLObjectResultSet
3232
33 @implementer(ISQLObjectResultSet)33 @implementer(ISQLObjectResultSet)
34 class TestSQLObjectResultSet(object):34 class TestSQLObjectResultSet:
35 _result_set = EmptyResultSet()35 _result_set = EmptyResultSet()
3636
3737
3838
=== modified file 'storm/tests/zope/testing.py'
--- storm/tests/zope/testing.py 2024-03-04 10:59:55 +0000
+++ storm/tests/zope/testing.py 2024-03-13 16:26:38 +0000
@@ -53,7 +53,7 @@
53 return has_transaction and has_zope_component and has_testresources53 return has_transaction and has_zope_component and has_testresources
5454
55 def setUp(self):55 def setUp(self):
56 super(ZStormResourceManagerTest, self).setUp()56 super().setUp()
57 package_dir = self.makeDir()57 package_dir = self.makeDir()
58 sys.path.append(package_dir)58 sys.path.append(package_dir)
59 self.patch_dir = os.path.join(package_dir, "patch_package")59 self.patch_dir = os.path.join(package_dir, "patch_package")
@@ -77,7 +77,7 @@
77 global_zstorm._reset()77 global_zstorm._reset()
78 del sys.modules["patch_package"]78 del sys.modules["patch_package"]
79 sys.modules.pop("patch_package.patch_1", None)79 sys.modules.pop("patch_package.patch_1", None)
80 super(ZStormResourceManagerTest, self).tearDown()80 super().tearDown()
8181
82 def test_make(self):82 def test_make(self):
83 """83 """
@@ -182,7 +182,7 @@
182 L{ZStormResourceManager.clean} tries to flush the stores to make sure182 L{ZStormResourceManager.clean} tries to flush the stores to make sure
183 that they are all in a consistent state.183 that they are all in a consistent state.
184 """184 """
185 class Test(object):185 class Test:
186 __storm_table__ = "test"186 __storm_table__ = "test"
187 foo = Unicode()187 foo = Unicode()
188 bar = Int(primary=True)188 bar = Int(primary=True)
@@ -193,8 +193,8 @@
193193
194 zstorm = self.resource.make([])194 zstorm = self.resource.make([])
195 store = zstorm.get("test")195 store = zstorm.get("test")
196 store.add(Test(u"data", 1))196 store.add(Test("data", 1))
197 store.add(Test(u"data", 2))197 store.add(Test("data", 2))
198 self.assertRaises(IntegrityError, self.resource.clean, zstorm)198 self.assertRaises(IntegrityError, self.resource.clean, zstorm)
199199
200 def test_clean_delete(self):200 def test_clean_delete(self):
@@ -227,7 +227,7 @@
227 L{ZStormResourceManager.clean} clears the alive cache before227 L{ZStormResourceManager.clean} clears the alive cache before
228 aborting the transaction.228 aborting the transaction.
229 """229 """
230 class Test(object):230 class Test:
231 __storm_table__ = "test"231 __storm_table__ = "test"
232 bar = Int(primary=True)232 bar = Int(primary=True)
233233
@@ -405,7 +405,7 @@
405 self.makeFile(path=os.path.join(self.patch_dir, "patch_2.py"),405 self.makeFile(path=os.path.join(self.patch_dir, "patch_2.py"),
406 content="def apply(store): pass")406 content="def apply(store): pass")
407407
408 class FakeStat(object):408 class FakeStat:
409 st_mtime = os.stat(self.patch_dir).st_mtime + 1409 st_mtime = os.stat(self.patch_dir).st_mtime + 1
410410
411 stat_mock = self.mocker.replace(os.stat)411 stat_mock = self.mocker.replace(os.stat)
412412
=== modified file 'storm/tests/zope/zstorm.py'
--- storm/tests/zope/zstorm.py 2024-03-04 10:59:55 +0000
+++ storm/tests/zope/zstorm.py 2024-03-13 16:26:38 +0000
@@ -136,8 +136,7 @@
136 stores.append((name, store))136 stores.append((name, store))
137 self.assertEqual(len(stores), 3)137 self.assertEqual(len(stores), 3)
138 self.assertEqual(set(stores),138 self.assertEqual(set(stores),
139 set([(None, store1), (None, store2),139 {(None, store1), (None, store2), ("name", store3)})
140 ("name", store3)]))
141140
142 def test_get_name(self):141 def test_get_name(self):
143 store = self.zstorm.create("name", "sqlite:")142 store = self.zstorm.create("name", "sqlite:")
144143
=== modified file 'storm/tracer.py'
--- storm/tracer.py 2024-03-04 10:59:55 +0000
+++ storm/tracer.py 2024-03-13 16:26:38 +0000
@@ -9,7 +9,7 @@
9from storm.expr import Variable9from storm.expr import Variable
1010
1111
12class DebugTracer(object):12class DebugTracer:
1313
14 def __init__(self, stream=None):14 def __init__(self, stream=None):
15 if stream is None:15 if stream is None:
@@ -53,7 +53,7 @@
53 self._stream.flush()53 self._stream.flush()
5454
5555
56class TimeoutTracer(object):56class TimeoutTracer:
57 """Provide a timeout facility for connections to prevent rogue operations.57 """Provide a timeout facility for connections to prevent rogue operations.
5858
59 This tracer must be subclassed by backend-specific implementations that59 This tracer must be subclassed by backend-specific implementations that
@@ -141,7 +141,7 @@
141 % self.__class__.__name__)141 % self.__class__.__name__)
142142
143143
144class BaseStatementTracer(object):144class BaseStatementTracer:
145 """Storm tracer base class that does query interpolation."""145 """Storm tracer base class that does query interpolation."""
146146
147 def connection_raw_execute(self, connection, raw_cursor,147 def connection_raw_execute(self, connection, raw_cursor,
@@ -207,7 +207,7 @@
207 on the connection object. If no name has been assigned, '<unknown>'207 on the connection object. If no name has been assigned, '<unknown>'
208 is used instead.208 is used instead.
209 """209 """
210 super(TimelineTracer, self).__init__()210 super().__init__()
211 self.timeline_factory = timeline_factory211 self.timeline_factory = timeline_factory
212 self.prefix = prefix212 self.prefix = prefix
213 # Stores the action in progress in a given thread.213 # Stores the action in progress in a given thread.
214214
=== modified file 'storm/twisted/testing.py'
--- storm/twisted/testing.py 2024-03-04 10:59:55 +0000
+++ storm/twisted/testing.py 2024-03-13 16:26:38 +0000
@@ -4,7 +4,7 @@
4from storm.twisted.transact import Transactor4from storm.twisted.transact import Transactor
55
66
7class FakeThreadPool(object):7class FakeThreadPool:
8 """8 """
9 A fake L{twisted.python.threadpool.ThreadPool}, running functions inside9 A fake L{twisted.python.threadpool.ThreadPool}, running functions inside
10 the main thread instead for easing tests.10 the main thread instead for easing tests.
@@ -21,7 +21,7 @@
21 onResult(success, result)21 onResult(success, result)
2222
2323
24class FakeTransaction(object):24class FakeTransaction:
2525
26 def commit(self):26 def commit(self):
27 pass27 pass
2828
=== modified file 'storm/twisted/transact.py'
--- storm/twisted/transact.py 2024-03-04 10:59:55 +0000
+++ storm/twisted/transact.py 2024-03-13 16:26:38 +0000
@@ -20,7 +20,7 @@
20 pass20 pass
2121
2222
23class Transactor(object):23class Transactor:
24 """Run in a thread code that needs to interact with the database.24 """Run in a thread code that needs to interact with the database.
2525
26 This class makes sure that code interacting with the database is run26 This class makes sure that code interacting with the database is run
@@ -105,7 +105,7 @@
105 return result105 return result
106106
107107
108class RetryContext(object):108class RetryContext:
109 """Hold details about a function that is going to be retried.109 """Hold details about a function that is going to be retried.
110110
111 @ivar function: The function that is going to be retried.111 @ivar function: The function that is going to be retried.
112112
=== modified file 'storm/tz.py'
--- storm/tz.py 2024-03-04 10:59:55 +0000
+++ storm/tz.py 2024-03-13 16:26:38 +0000
@@ -149,7 +149,7 @@
149149
150 __reduce__ = object.__reduce__150 __reduce__ = object.__reduce__
151151
152class _ttinfo(object):152class _ttinfo:
153 __slots__ = ["offset", "delta", "isdst", "abbr", "isstd", "isgmt"]153 __slots__ = ["offset", "delta", "isdst", "abbr", "isstd", "isgmt"]
154154
155 def __init__(self):155 def __init__(self):
@@ -889,7 +889,7 @@
889 try:889 try:
890 tz = tzfile(filepath)890 tz = tzfile(filepath)
891 break891 break
892 except (IOError, OSError, ValueError):892 except (OSError, ValueError):
893 pass893 pass
894 else:894 else:
895 tz = tzlocal()895 tz = tzlocal()
@@ -911,7 +911,7 @@
911 try:911 try:
912 tz = tzfile(filepath)912 tz = tzfile(filepath)
913 break913 break
914 except (IOError, OSError, ValueError):914 except (OSError, ValueError):
915 pass915 pass
916 else:916 else:
917 tz = None917 tz = None
918918
=== modified file 'storm/uri.py'
--- storm/uri.py 2024-03-04 10:59:55 +0000
+++ storm/uri.py 2024-03-13 16:26:38 +0000
@@ -23,7 +23,7 @@
23from storm.exceptions import URIError23from storm.exceptions import URIError
2424
2525
26class URI(object):26class URI:
27 """A representation of a Uniform Resource Identifier (URI).27 """A representation of a Uniform Resource Identifier (URI).
2828
29 This is intended exclusively for database connection URIs.29 This is intended exclusively for database connection URIs.
3030
=== modified file 'storm/variables.py'
--- storm/variables.py 2024-03-04 10:59:55 +0000
+++ storm/variables.py 2024-03-13 16:26:38 +0000
@@ -54,7 +54,7 @@
54]54]
5555
5656
57class LazyValue(object):57class LazyValue:
58 """Marker to be used as a base class on lazily evaluated values."""58 """Marker to be used as a base class on lazily evaluated values."""
59 __slots__ = ()59 __slots__ = ()
6060
@@ -79,7 +79,7 @@
79VariableFactory = partial79VariableFactory = partial
8080
8181
82class Variable(object):82class Variable:
83 """Basic representation of a database value in Python.83 """Basic representation of a database value in Python.
8484
85 @type column: L{storm.expr.Column}85 @type column: L{storm.expr.Column}
@@ -394,7 +394,7 @@
394394
395 def __init__(self, *args, **kwargs):395 def __init__(self, *args, **kwargs):
396 self._tzinfo = kwargs.pop("tzinfo", None)396 self._tzinfo = kwargs.pop("tzinfo", None)
397 super(DateTimeVariable, self).__init__(*args, **kwargs)397 super().__init__(*args, **kwargs)
398398
399 def parse_set(self, value, from_db):399 def parse_set(self, value, from_db):
400 if from_db:400 if from_db:
@@ -579,7 +579,7 @@
579 def get(self, default=None, to_db=False):579 def get(self, default=None, to_db=False):
580 if self._event_system is not None:580 if self._event_system is not None:
581 self._event_system.hook("flush", self._detect_changes)581 self._event_system.hook("flush", self._detect_changes)
582 return super(MutableValueVariable, self).get(default, to_db)582 return super().get(default, to_db)
583583
584 def set(self, value, from_db=False):584 def set(self, value, from_db=False):
585 if self._event_system is not None:585 if self._event_system is not None:
@@ -587,7 +587,7 @@
587 self._event_system.unhook("flush", self._detect_changes)587 self._event_system.unhook("flush", self._detect_changes)
588 else:588 else:
589 self._event_system.hook("flush", self._detect_changes)589 self._event_system.hook("flush", self._detect_changes)
590 super(MutableValueVariable, self).set(value, from_db)590 super().set(value, from_db)
591591
592592
593class EncodedValueVariable(MutableValueVariable):593class EncodedValueVariable(MutableValueVariable):
594594
=== modified file 'storm/xid.py'
--- storm/xid.py 2024-03-04 10:59:55 +0000
+++ storm/xid.py 2024-03-13 16:26:38 +0000
@@ -19,7 +19,7 @@
19# along with this program. If not, see <http://www.gnu.org/licenses/>.19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#20#
2121
22class Xid(object):22class Xid:
23 """23 """
24 Represent a transaction identifier compliant with the XA specification.24 Represent a transaction identifier compliant with the XA specification.
25 """25 """
2626
=== modified file 'storm/zope/metadirectives.py'
--- storm/zope/metadirectives.py 2024-03-04 10:59:55 +0000
+++ storm/zope/metadirectives.py 2024-03-13 16:26:38 +0000
@@ -24,5 +24,5 @@
2424
25class IStoreDirective(Interface):25class IStoreDirective(Interface):
2626
27 name = TextLine(title=u"Name", description=u"Store name")27 name = TextLine(title="Name", description="Store name")
28 uri = TextLine(title=u"URI", description=u"Database URI")28 uri = TextLine(title="URI", description="Database URI")
2929
=== modified file 'storm/zope/schema.py'
--- storm/zope/schema.py 2024-03-04 10:59:55 +0000
+++ storm/zope/schema.py 2024-03-13 16:26:38 +0000
@@ -24,7 +24,7 @@
24from storm.schema import Schema24from storm.schema import Schema
2525
2626
27class ZCommitter(object):27class ZCommitter:
28 """A L{Schema} committer that uses Zope's transaction manager."""28 """A L{Schema} committer that uses Zope's transaction manager."""
2929
30 def commit(self):30 def commit(self):
@@ -39,5 +39,4 @@
3939
40 def __init__(self, creates, drops, deletes, patch_package):40 def __init__(self, creates, drops, deletes, patch_package):
41 committer = ZCommitter()41 committer = ZCommitter()
42 super(ZSchema, self).__init__(creates, drops, deletes, patch_package,42 super().__init__(creates, drops, deletes, patch_package, committer)
43 committer)
4443
=== modified file 'storm/zope/testing.py'
--- storm/zope/testing.py 2024-03-04 10:59:55 +0000
+++ storm/zope/testing.py 2024-03-13 16:26:38 +0000
@@ -70,7 +70,7 @@
70 vertical_patching = True70 vertical_patching = True
7171
72 def __init__(self, databases):72 def __init__(self, databases):
73 super(ZStormResourceManager, self).__init__()73 super().__init__()
74 self._databases = databases74 self._databases = databases
75 self._zstorm = None75 self._zstorm = None
76 self._schema_zstorm = None76 self._schema_zstorm = None
7777
=== modified file 'storm/zope/zstorm.py'
--- storm/zope/zstorm.py 2024-03-04 10:59:55 +0000
+++ storm/zope/zstorm.py 2024-03-13 16:26:38 +0000
@@ -45,7 +45,7 @@
4545
4646
47@implementer(IZStorm)47@implementer(IZStorm)
48class ZStorm(object):48class ZStorm:
49 """A utility which integrates Storm with Zope.49 """A utility which integrates Storm with Zope.
5050
51 Typically, applications will register stores using ZCML similar51 Typically, applications will register stores using ZCML similar
@@ -255,7 +255,7 @@
255255
256256
257@implementer(IDataManager)257@implementer(IDataManager)
258class StoreDataManager(object):258class StoreDataManager:
259 """An L{IDataManager} implementation for C{ZStorm}."""259 """An L{IDataManager} implementation for C{ZStorm}."""
260260
261 def __init__(self, store, zstorm):261 def __init__(self, store, zstorm):

Subscribers

People subscribed via source and target branches

to status/vote changes: