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)):
import copy
import inspect
import operator
-import sets
import sys
import weakref
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."""
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
"""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
# 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
mapper(Address, addresses)
class UCComparator(sa.orm.PropComparator):
+ __hash__ = None
+
def __eq__(self, other):
cls = self.prop.parent.class_
col = getattr(cls, 'name')
return 'value'
class UCComparator(sa.orm.PropComparator):
+ __hash__ = None
def __eq__(self, other):
cls = self.prop.parent.class_
col = getattr(cls, 'name')
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)})
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)})
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)
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):
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):
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):
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):
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):
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
equivalent = _received_statement == sql
if self.params:
- if callable(self.params):
+ if util.callable(self.params):
params = self.params(context)
else:
params = self.params
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
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
__email__ = "stephen_purcell at yahoo dot com"
__version__ = "#Revision: 1.63 $"[11:-2]
+from sqlalchemy.util import callable
import time
import sys
import traceback
__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
##############################################################################
criteria and returning them wrapped in a Test
"""
testMethodPrefix = 'test'
- sortTestMethodsUsing = cmp
suiteClass = TestSuite
def loadTestsFromTestCase(self, testCaseClass):
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))
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
def _makeLoader(prefix, sortUsing, suiteClass=None):
loader = TestLoader()
- loader.sortTestMethodsUsing = sortUsing
loader.testMethodPrefix = prefix
if suiteClass: loader.suiteClass = suiteClass
return loader