aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYury Selivanov <yury@edgedb.com>2020-05-17 21:36:03 -0700
committerYury Selivanov <yury@edgedb.com>2020-05-17 21:36:03 -0700
commit7b28a1275a80dfcfefaa9775dbf5f3231e3952a1 (patch)
tree95b37fbede5398ef617584f13049a87fbbeb5b1b /tests
parent913572c2ef8a4c948bb8b67ff2064d6920e313e7 (diff)
downloadimmutables-7b28a1275a80dfcfefaa9775dbf5f3231e3952a1.tar.gz
immutables-7b28a1275a80dfcfefaa9775dbf5f3231e3952a1.zip
Unbreak CI
Diffstat (limited to 'tests')
-rw-r--r--tests/test_map.py83
-rw-r--r--tests/test_none_keys.py2
2 files changed, 2 insertions, 83 deletions
diff --git a/tests/test_map.py b/tests/test_map.py
index 37b5b65..b6ee7f1 100644
--- a/tests/test_map.py
+++ b/tests/test_map.py
@@ -7,88 +7,7 @@ import unittest
import weakref
from immutables.map import Map as PyMap
-
-
-class HashKey:
- _crasher = None
-
- def __init__(self, hash, name, *, error_on_eq_to=None):
- assert hash != -1
- self.name = name
- self.hash = hash
- self.error_on_eq_to = error_on_eq_to
-
- def __repr__(self):
- if self._crasher is not None and self._crasher.error_on_repr:
- raise ReprError
- return '<Key name:{} hash:{}>'.format(self.name, self.hash)
-
- def __hash__(self):
- if self._crasher is not None and self._crasher.error_on_hash:
- raise HashingError
-
- return self.hash
-
- def __eq__(self, other):
- if not isinstance(other, HashKey):
- return NotImplemented
-
- if self._crasher is not None and self._crasher.error_on_eq:
- raise EqError
-
- if self.error_on_eq_to is not None and self.error_on_eq_to is other:
- raise ValueError('cannot compare {!r} to {!r}'.format(self, other))
- if other.error_on_eq_to is not None and other.error_on_eq_to is self:
- raise ValueError('cannot compare {!r} to {!r}'.format(other, self))
-
- return (self.name, self.hash) == (other.name, other.hash)
-
-
-class KeyStr(str):
-
- def __hash__(self):
- if HashKey._crasher is not None and HashKey._crasher.error_on_hash:
- raise HashingError
- return super().__hash__()
-
- def __eq__(self, other):
- if HashKey._crasher is not None and HashKey._crasher.error_on_eq:
- raise EqError
- return super().__eq__(other)
-
- def __repr__(self, other):
- if HashKey._crasher is not None and HashKey._crasher.error_on_repr:
- raise ReprError
- return super().__eq__(other)
-
-
-class HashKeyCrasher:
-
- def __init__(self, *, error_on_hash=False, error_on_eq=False,
- error_on_repr=False):
- self.error_on_hash = error_on_hash
- self.error_on_eq = error_on_eq
- self.error_on_repr = error_on_repr
-
- def __enter__(self):
- if HashKey._crasher is not None:
- raise RuntimeError('cannot nest crashers')
- HashKey._crasher = self
-
- def __exit__(self, *exc):
- HashKey._crasher = None
-
-
-class HashingError(Exception):
- pass
-
-
-class EqError(Exception):
- pass
-
-
-class ReprError(Exception):
- pass
+from immutables._testutils import * # NoQA
class BaseMapTest:
diff --git a/tests/test_none_keys.py b/tests/test_none_keys.py
index 3662e9c..f7969f3 100644
--- a/tests/test_none_keys.py
+++ b/tests/test_none_keys.py
@@ -1,7 +1,7 @@
import unittest
from immutables.map import map_hash, map_mask, Map as PyMap
-from tests.test_map import HashKey
+from immutables._testutils import * # NoQA
none_hash = map_hash(None)