summaryrefslogtreecommitdiff
path: root/test/base/test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r--test/base/test_utils.py139
1 files changed, 0 insertions, 139 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py
index 246199861..96a9f955a 100644
--- a/test/base/test_utils.py
+++ b/test/base/test_utils.py
@@ -9,7 +9,6 @@ from sqlalchemy import exc
from sqlalchemy import sql
from sqlalchemy import testing
from sqlalchemy import util
-from sqlalchemy.engine import result
from sqlalchemy.sql import column
from sqlalchemy.sql.base import DedupeColumnCollection
from sqlalchemy.testing import assert_raises
@@ -33,144 +32,6 @@ from sqlalchemy.util import timezone
from sqlalchemy.util import WeakSequence
-class _KeyedTupleTest(object):
- def _fixture(self, values, labels):
- raise NotImplementedError()
-
- def test_empty(self):
- keyed_tuple = self._fixture([], [])
- eq_(str(keyed_tuple), "()")
- eq_(len(keyed_tuple), 0)
-
- eq_(list(keyed_tuple._mapping.keys()), [])
- eq_(keyed_tuple._fields, ())
- eq_(keyed_tuple._asdict(), {})
-
- def test_values_none_labels(self):
- keyed_tuple = self._fixture([1, 2], [None, None])
- eq_(str(keyed_tuple), "(1, 2)")
- eq_(len(keyed_tuple), 2)
-
- eq_(list(keyed_tuple._mapping.keys()), [])
- eq_(keyed_tuple._fields, ())
- eq_(keyed_tuple._asdict(), {})
-
- eq_(keyed_tuple[0], 1)
- eq_(keyed_tuple[1], 2)
-
- def test_creation(self):
- keyed_tuple = self._fixture([1, 2], ["a", "b"])
- eq_(str(keyed_tuple), "(1, 2)")
- eq_(list(keyed_tuple._mapping.keys()), ["a", "b"])
- eq_(keyed_tuple._fields, ("a", "b"))
- eq_(keyed_tuple._asdict(), {"a": 1, "b": 2})
-
- def test_index_access(self):
- keyed_tuple = self._fixture([1, 2], ["a", "b"])
- eq_(keyed_tuple[0], 1)
- eq_(keyed_tuple[1], 2)
-
- def should_raise():
- keyed_tuple[2]
-
- assert_raises(IndexError, should_raise)
-
- def test_slice_access(self):
- keyed_tuple = self._fixture([1, 2], ["a", "b"])
- eq_(keyed_tuple[0:2], (1, 2))
-
- def test_attribute_access(self):
- keyed_tuple = self._fixture([1, 2], ["a", "b"])
- eq_(keyed_tuple.a, 1)
- eq_(keyed_tuple.b, 2)
-
- def should_raise():
- keyed_tuple.c
-
- assert_raises(AttributeError, should_raise)
-
- def test_contains(self):
- keyed_tuple = self._fixture(["x", "y"], ["a", "b"])
-
- is_true("x" in keyed_tuple)
- is_false("z" in keyed_tuple)
-
- is_true("z" not in keyed_tuple)
- is_false("x" not in keyed_tuple)
-
- # we don't do keys
- is_false("a" in keyed_tuple)
- is_false("z" in keyed_tuple)
- is_true("a" not in keyed_tuple)
- is_true("z" not in keyed_tuple)
-
- def test_none_label(self):
- keyed_tuple = self._fixture([1, 2, 3], ["a", None, "b"])
- eq_(str(keyed_tuple), "(1, 2, 3)")
-
- eq_(list(keyed_tuple._mapping.keys()), ["a", "b"])
- eq_(keyed_tuple._fields, ("a", "b"))
- eq_(keyed_tuple._asdict(), {"a": 1, "b": 3})
-
- # attribute access: can't get at value 2
- eq_(keyed_tuple.a, 1)
- eq_(keyed_tuple.b, 3)
-
- # index access: can get at value 2
- eq_(keyed_tuple[0], 1)
- eq_(keyed_tuple[1], 2)
- eq_(keyed_tuple[2], 3)
-
- def test_duplicate_labels(self):
- keyed_tuple = self._fixture([1, 2, 3], ["a", "b", "b"])
- eq_(str(keyed_tuple), "(1, 2, 3)")
-
- eq_(list(keyed_tuple._mapping.keys()), ["a", "b", "b"])
- eq_(keyed_tuple._fields, ("a", "b", "b"))
- eq_(keyed_tuple._asdict(), {"a": 1, "b": 3})
-
- # attribute access: can't get at value 2
- eq_(keyed_tuple.a, 1)
- eq_(keyed_tuple.b, 3)
-
- # index access: can get at value 2
- eq_(keyed_tuple[0], 1)
- eq_(keyed_tuple[1], 2)
- eq_(keyed_tuple[2], 3)
-
- def test_immutable(self):
- keyed_tuple = self._fixture([1, 2], ["a", "b"])
- eq_(str(keyed_tuple), "(1, 2)")
-
- eq_(keyed_tuple.a, 1)
-
- # eh
- # assert_raises(AttributeError, setattr, keyed_tuple, "a", 5)
-
- def should_raise():
- keyed_tuple[0] = 100
-
- assert_raises(TypeError, should_raise)
-
- def test_serialize(self):
-
- keyed_tuple = self._fixture([1, 2, 3], ["a", None, "b"])
-
- for loads, dumps in picklers():
- kt = loads(dumps(keyed_tuple))
-
- eq_(str(kt), "(1, 2, 3)")
-
- eq_(list(kt._mapping.keys()), ["a", "b"])
- eq_(kt._fields, ("a", "b"))
- eq_(kt._asdict(), {"a": 1, "b": 3})
-
-
-class LWKeyedTupleTest(_KeyedTupleTest, fixtures.TestBase):
- def _fixture(self, values, labels):
- return result.result_tuple(labels)(values)
-
-
class WeakSequenceTest(fixtures.TestBase):
@testing.requires.predictable_gc
def test_cleanout_elements(self):