diff options
author | Tim Harder <radhermit@gmail.com> | 2021-03-15 15:30:23 -0600 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2021-03-15 15:31:04 -0600 |
commit | 9b72db98414e65d674647837f960791d1489003d (patch) | |
tree | 740b53ca00b5f666491c4647147b74fd5aa9b74e /tests | |
parent | klass: Fix ignore_missing=True in steal_docs() (diff) | |
download | snakeoil-9b72db98414e65d674647837f960791d1489003d.tar.gz snakeoil-9b72db98414e65d674647837f960791d1489003d.tar.bz2 snakeoil-9b72db98414e65d674647837f960791d1489003d.zip |
weakrefs: drop old WeakValCache support
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_weakrefs.py | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/tests/test_weakrefs.py b/tests/test_weakrefs.py deleted file mode 100644 index 79b2a34..0000000 --- a/tests/test_weakrefs.py +++ /dev/null @@ -1,73 +0,0 @@ -from weakref import WeakValueDictionary - -import pytest - -from snakeoil.weakrefs import WeakValCache - - -class RefObj: - pass - - -@pytest.mark.skipif( - WeakValueDictionary is WeakValCache, - reason="WeakValCache is weakref.WeakValueDictionary; indicates " - "snakeoil._caching isn't compiled") -class TestWeakValCache: - - def setup_method(self, method): - self.o = RefObj() - self.w = WeakValCache() - - def test_setitem(self): - s = "asdf" - self.w[s] = self.o - self.w["fds"] = self.o - self.w[s] = self.o - - def test_getitem(self): - s = "asdf" - self.w[s] = self.o - assert self.w[s] is self.o - - def test_expiring(self): - s = "asdf" - self.w[s] = self.o - assert self.w[s] - del self.o - with pytest.raises(KeyError): - self.w.__getitem__(s) - - def test_get(self): - s = "asdf" - with pytest.raises(KeyError): - self.w.__getitem__(s) - self.w[s] = self.o - assert self.w.get(s) is self.o - - def test_keys(self): - assert list(self.w.keys()) == [] - self.w['a'] = self.o - self.w['b'] = self.o - self.w['c'] = self.o - assert sorted(self.w.keys()) == ['a', 'b', 'c'] - del self.o - assert self.w.keys() == [] - - def test_values(self): - assert list(self.w.values()) == [] - self.w['a'] = self.o - self.w['b'] = self.o - self.w['c'] = self.o - assert len(iter(self.w.values())) == 3 - del self.o - assert self.w.values() == [] - - def test_items(self): - assert list(self.w.items()) == [] - self.w['a'] = self.o - self.w['b'] = self.o - self.w['c'] = self.o - assert len(iter(self.w.items())) == 3 - del self.o - assert self.w.items() == [] |