Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete .tearDown() methods from unit test classes #310

Merged
merged 1 commit into from
Dec 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ def setUp(self) -> None:
url = f'redis://localhost:6379/{self.redis_db}'
self.redis = Redis.from_url(url, socket_timeout=1)
self.redis.flushdb()

def tearDown(self) -> None:
self.redis.flushdb()
super().tearDown()
self.addCleanup(self.redis.flushdb)


def run_doctests() -> NoReturn: # pragma: no cover
Expand Down
4 changes: 0 additions & 4 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ def setUp(self):
vegetarian=False,
)

def tearDown(self):
self.redis.delete('luvh')
super().tearDown()


class CommonTests(_BaseTestCase):
def test_out_of_scope(self):
Expand Down
3 changes: 0 additions & 3 deletions tests/test_bloom.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ def setUp(self):
false_positives=0.001,
)

def tearDown(self):
super().tearDown()

@staticmethod
def random_fullname(*, prefix='t3_', size=6):
alphabet, id36 = string.digits + string.ascii_lowercase, ''
Expand Down
5 changes: 0 additions & 5 deletions tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ def expensive_method(*args, **kwargs):
self.expensive_method_expiration.cache_clear()
self.expensive_method_no_expiration.cache_clear()

def tearDown(self):
self.expensive_method_expiration.cache_clear()
self.expensive_method_no_expiration.cache_clear()
super().tearDown()

def test_cache(self):
assert self.expensive_method_expiration.cache_info() == CacheInfo(
hits=0,
Expand Down
4 changes: 0 additions & 4 deletions tests/test_nextid.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ def setUp(self):
for master in self.ids.masters:
master.set(self.ids.key, 0)

def tearDown(self):
self.redis.delete('nextid:current')
super().tearDown()

def test_nextid(self):
for id_ in range(1, 10):
with self.subTest(id_=id_):
Expand Down
6 changes: 0 additions & 6 deletions tests/test_redlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


import concurrent.futures
import contextlib
import time

from pottery import ContextTimer
Expand All @@ -31,11 +30,6 @@ def setUp(self):
auto_release_time=100,
)

def tearDown(self):
with contextlib.suppress(AttributeError, ReleaseUnlockedLock):
self.redlock.release()
super().tearDown()

def test_acquire_and_time_out(self):
assert not self.redis.exists(self.redlock.key)
assert self.redlock.acquire()
Expand Down