From 5ddce0ea00ff0534392ecabbb17b74becdcee4aa Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 18 Dec 2008 18:46:27 +0000 Subject: *most* py3k warnings are resolved, with the exception of the various __setslice__ related warnings I don't really know how to get rid of --- test/orm/inheritance/polymorph.py | 1 - test/orm/inheritance/query.py | 1 - test/orm/mapper.py | 12 ++++++++++++ test/testlib/assertsql.py | 7 ++++--- test/testlib/sa_unittest.py | 23 +++-------------------- 5 files changed, 19 insertions(+), 25 deletions(-) (limited to 'test') 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 @@ -52,22 +53,6 @@ __all__ = ['TestResult', 'TestCase', 'TestSuite', 'TextTestRunner', __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 -- cgit v1.2.1