From 7b28a1275a80dfcfefaa9775dbf5f3231e3952a1 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Sun, 17 May 2020 21:36:03 -0700 Subject: Unbreak CI --- tests/test_map.py | 83 +------------------------------------------------ tests/test_none_keys.py | 2 +- 2 files changed, 2 insertions(+), 83 deletions(-) (limited to 'tests') 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 ''.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) -- cgit v1.2.3