mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-17 22:22:13 -04:00
*most* py3k warnings are resolved, with the exception of the various __setslice__ related warnings
I don't really know how to get rid of
This commit is contained in:
@@ -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)):
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user