diff options
-rw-r--r-- | lib/sqlalchemy/databases/mssql.py | 2 | ||||
-rw-r--r-- | lib/sqlalchemy/orm/collections.py | 7 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 2 | ||||
-rw-r--r-- | test/orm/inheritance/polymorph.py | 1 | ||||
-rw-r--r-- | test/orm/inheritance/query.py | 1 | ||||
-rw-r--r-- | test/orm/mapper.py | 12 | ||||
-rw-r--r-- | test/testlib/assertsql.py | 7 | ||||
-rw-r--r-- | test/testlib/sa_unittest.py | 23 |
8 files changed, 26 insertions, 29 deletions
diff --git a/lib/sqlalchemy/databases/mssql.py b/lib/sqlalchemy/databases/mssql.py index 5fb4361b9..84f95fad9 100644 --- a/lib/sqlalchemy/databases/mssql.py +++ b/lib/sqlalchemy/databases/mssql.py @@ -1044,7 +1044,7 @@ class MSSQLCompiler(compiler.DefaultCompiler): and not isinstance(binary.right, expression._BindParamClause): return self.process(expression._BinaryExpression(binary.right, binary.left, binary.operator), **kwargs) else: - if (binary.operator in (operator.eq, operator.ne)) and ( + if (binary.operator is operator.eq or binary.operator is operator.ne) and ( (isinstance(binary.left, expression._FromGrouping) and isinstance(binary.left.element, expression._ScalarSelect)) or \ (isinstance(binary.right, expression._FromGrouping) and isinstance(binary.right.element, expression._ScalarSelect)) or \ isinstance(binary.left, expression._ScalarSelect) or isinstance(binary.right, expression._ScalarSelect)): diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py index 3c1c16b7d..5638a7e4a 100644 --- a/lib/sqlalchemy/orm/collections.py +++ b/lib/sqlalchemy/orm/collections.py @@ -99,7 +99,6 @@ through the adapter, allowing for some very sophisticated behavior. import copy import inspect import operator -import sets import sys import weakref @@ -1128,7 +1127,11 @@ def _dict_decorators(): l.pop('Unspecified') return l -_set_binop_bases = (set, frozenset, sets.BaseSet) +if util.py3k: + _set_binop_bases = (set, frozenset) +else: + import sets + _set_binop_bases = (set, frozenset, sets.BaseSet) def _set_binops_check_strict(self, obj): """Allow only set, frozenset and self.__class__-derived objects in binops.""" diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index a4ff72b1a..b7d4965dd 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -2128,7 +2128,7 @@ class ClauseList(ClauseElement): return list(itertools.chain(*[c._from_objects for c in self.clauses])) def self_group(self, against=None): - if self.group and self.operator != against and operators.is_precedent(self.operator, against): + if self.group and self.operator is not against and operators.is_precedent(self.operator, against): return _Grouping(self) else: return self diff --git a/test/orm/inheritance/polymorph.py b/test/orm/inheritance/polymorph.py index cbdbd4c00..aa241cea8 100644 --- a/test/orm/inheritance/polymorph.py +++ b/test/orm/inheritance/polymorph.py @@ -1,7 +1,6 @@ """tests basic polymorphic mapper loading/saving, minimal relations""" import testenv; testenv.configure_for_tests() -import sets from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.orm import exc as orm_exc diff --git a/test/orm/inheritance/query.py b/test/orm/inheritance/query.py index 601d5be6c..f362ea097 100644 --- a/test/orm/inheritance/query.py +++ b/test/orm/inheritance/query.py @@ -4,7 +4,6 @@ and inheriting mappers.""" # TODO: under construction ! import testenv; testenv.configure_for_tests() -import sets from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy import exc as sa_exc diff --git a/test/orm/mapper.py b/test/orm/mapper.py index 6fa532043..e30b53428 100644 --- a/test/orm/mapper.py +++ b/test/orm/mapper.py @@ -222,6 +222,8 @@ class MapperTest(_fixtures.FixtureTest): mapper(Address, addresses) class UCComparator(sa.orm.PropComparator): + __hash__ = None + def __eq__(self, other): cls = self.prop.parent.class_ col = getattr(cls, 'name') @@ -696,6 +698,7 @@ class MapperTest(_fixtures.FixtureTest): return 'value' class UCComparator(sa.orm.PropComparator): + __hash__ = None def __eq__(self, other): cls = self.prop.parent.class_ col = getattr(cls, 'name') @@ -1158,6 +1161,7 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL): from sqlalchemy.orm.properties import ColumnProperty class MyFactory(ColumnProperty.Comparator): + __hash__ = None def __eq__(self, other): return func.foobar(self.__clause_element__()) == func.foobar(other) mapper(User, users, properties={'name':column_property(users.c.name, comparator_factory=MyFactory)}) @@ -1168,6 +1172,7 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL): def test_synonym(self): from sqlalchemy.orm.properties import ColumnProperty class MyFactory(ColumnProperty.Comparator): + __hash__ = None def __eq__(self, other): return func.foobar(self.__clause_element__()) == func.foobar(other) mapper(User, users, properties={'name':synonym('_name', map_column=True, comparator_factory=MyFactory)}) @@ -1179,10 +1184,12 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL): from sqlalchemy.orm.properties import PropertyLoader class MyFactory(PropertyLoader.Comparator): + __hash__ = None def __eq__(self, other): return func.foobar(self.__clause_element__().c.user_id) == func.foobar(other.id) class MyFactory2(PropertyLoader.Comparator): + __hash__ = None def __eq__(self, other): return func.foobar(self.__clause_element__().c.id) == func.foobar(other.user_id) @@ -1610,6 +1617,7 @@ class CompositeTypesTest(_base.MappedTest): self.y = y def __composite_values__(self): return [self.x, self.y] + __hash__ = None def __eq__(self, other): return other.x == self.x and other.y == self.y def __ne__(self, other): @@ -1689,6 +1697,7 @@ class CompositeTypesTest(_base.MappedTest): self.version = version def __composite_values__(self): return (self.id, self.version) + __hash__ = None def __eq__(self, other): return other.id == self.id and other.version == self.version def __ne__(self, other): @@ -1748,6 +1757,7 @@ class CompositeTypesTest(_base.MappedTest): self.x4 = x4 def __composite_values__(self): return self.x1, self.x2, self.x3, self.x4 + __hash__ = None def __eq__(self, other): return other.x1 == self.x1 and other.x2 == self.x2 and other.x3 == self.x3 and other.x4 == self.x4 def __ne__(self, other): @@ -1783,6 +1793,7 @@ class CompositeTypesTest(_base.MappedTest): self.x2val = x2 self.x3 = x3 self.x4 = x4 + __hash__ = None def __eq__(self, other): return other.x1val == self.x1val and other.x2val == self.x2val and other.x3 == self.x3 and other.x4 == self.x4 def __ne__(self, other): @@ -1814,6 +1825,7 @@ class CompositeTypesTest(_base.MappedTest): self.y = y def __composite_values__(self): return [self.x, self.y] + __hash__ = None def __eq__(self, other): return other.x == self.x and other.y == self.y def __ne__(self, other): diff --git a/test/testlib/assertsql.py b/test/testlib/assertsql.py index 1cafd041a..dc2c6d40f 100644 --- a/test/testlib/assertsql.py +++ b/test/testlib/assertsql.py @@ -2,6 +2,7 @@ from sqlalchemy.interfaces import ConnectionProxy from sqlalchemy.engine.default import DefaultDialect from sqlalchemy.engine.base import Connection +from sqlalchemy import util import testing import re @@ -72,7 +73,7 @@ class ExactSQL(SQLMatchRule): equivalent = _received_statement == sql if self.params: - if callable(self.params): + if util.callable(self.params): params = self.params(context) else: params = self.params @@ -106,7 +107,7 @@ class RegexSQL(SQLMatchRule): equivalent = bool(self.regex.match(_received_statement)) if self.params: - if callable(self.params): + if util.callable(self.params): params = self.params(context) else: params = self.params @@ -148,7 +149,7 @@ class CompiledSQL(SQLMatchRule): equivalent = self.statement == _received_statement if self.params: - if callable(self.params): + if util.callable(self.params): params = self.params(context) else: params = self.params diff --git a/test/testlib/sa_unittest.py b/test/testlib/sa_unittest.py index 912d7eb4d..8eb885829 100644 --- a/test/testlib/sa_unittest.py +++ b/test/testlib/sa_unittest.py @@ -36,6 +36,7 @@ __author__ = "Steve Purcell" __email__ = "stephen_purcell at yahoo dot com" __version__ = "#Revision: 1.63 $"[11:-2] +from sqlalchemy.util import callable import time import sys import traceback @@ -53,22 +54,6 @@ __all__.extend(['getTestCaseNames', 'makeSuite', 'findTestCases']) ############################################################################## -# Backward compatibility -############################################################################## -if sys.version_info[:2] < (2, 2): - False, True = 0, 1 - def isinstance(obj, clsinfo): - import __builtin__ - if type(clsinfo) in (tuple, list): - for cls in clsinfo: - if cls is type: cls = types.ClassType - if __builtin__.isinstance(obj, cls): - return 1 - return 0 - else: return __builtin__.isinstance(obj, clsinfo) - - -############################################################################## # Test framework core ############################################################################## @@ -482,7 +467,6 @@ class TestLoader: criteria and returning them wrapped in a Test """ testMethodPrefix = 'test' - sortTestMethodsUsing = cmp suiteClass = TestSuite def loadTestsFromTestCase(self, testCaseClass): @@ -556,6 +540,7 @@ class TestLoader: def getTestCaseNames(self, testCaseClass): """Return a sorted sequence of method names found within testCaseClass """ + def isTestMethod(attrname, testCaseClass=testCaseClass, prefix=self.testMethodPrefix): return attrname.startswith(prefix) and callable(getattr(testCaseClass, attrname)) testFnNames = filter(isTestMethod, dir(testCaseClass)) @@ -563,8 +548,7 @@ class TestLoader: for testFnName in self.getTestCaseNames(baseclass): if testFnName not in testFnNames: # handle overridden methods testFnNames.append(testFnName) - if self.sortTestMethodsUsing: - testFnNames.sort(self.sortTestMethodsUsing) + testFnNames.sort() return testFnNames @@ -578,7 +562,6 @@ defaultTestLoader = TestLoader() def _makeLoader(prefix, sortUsing, suiteClass=None): loader = TestLoader() - loader.sortTestMethodsUsing = sortUsing loader.testMethodPrefix = prefix if suiteClass: loader.suiteClass = suiteClass return loader |