Skip to content

Commit

Permalink
Clean up unnecessary test teardowns via @pacrob
Browse files Browse the repository at this point in the history
  • Loading branch information
fselmo committed Oct 31, 2022
1 parent ad1ef92 commit 3f20e8c
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions tests/core/middleware/test_simple_cache_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ def async_w3():
),
)
async def test_async_simple_cache_middleware_pulls_from_cache(async_w3, cache_class):
# remove the pre-loaded simple cache middleware to replace with test-specific:
async_w3.middleware_onion.remove("simple_cache")

async def _properly_awaited_middleware(make_request, _async_w3):
middleware = await async_construct_simple_cache_middleware(
cache_class=cache_class,
Expand All @@ -221,20 +218,12 @@ async def _properly_awaited_middleware(make_request, _async_w3):

async_w3.middleware_onion.inject(
_properly_awaited_middleware,
"for_this_test_only",
layer=0,
)

_result = await async_w3.manager.coro_request("fake_endpoint", [1])
assert _result == "value-a"

# -- teardown -- #
async_w3.middleware_onion.remove("for_this_test_only")
# add back the pre-loaded simple cache middleware:
async_w3.middleware_onion.add(
_async_simple_cache_middleware_for_testing, "simple_cache"
)


@pytest.mark.asyncio
async def test_async_simple_cache_middleware_populates_cache(async_w3):
Expand All @@ -256,9 +245,6 @@ async def test_async_simple_cache_middleware_populates_cache(async_w3):
assert _empty_params == result
assert _non_empty_params != result

# -- teardown -- #
async_w3.middleware_onion.remove("result_generator")


@pytest.mark.asyncio
async def test_async_simple_cache_middleware_does_not_cache_none_responses(async_w3):
Expand All @@ -283,9 +269,6 @@ def result_cb(_method, _params):

assert next(counter) == 2

# -- teardown -- #
async_w3.middleware_onion.remove("result_generator")


@pytest.mark.asyncio
async def test_async_simple_cache_middleware_does_not_cache_error_responses(async_w3):
Expand All @@ -306,9 +289,6 @@ async def test_async_simple_cache_middleware_does_not_cache_error_responses(asyn

assert str(err_a) != str(err_b)

# -- teardown -- #
async_w3.middleware_onion.remove("error_generator")


@pytest.mark.asyncio
async def test_async_simple_cache_middleware_does_not_cache_non_whitelist_endpoints(
Expand All @@ -320,14 +300,10 @@ async def test_async_simple_cache_middleware_does_not_cache_non_whitelist_endpoi
RPCEndpoint("not_whitelisted"): lambda *_: str(uuid.uuid4()),
}
),
"result_generator",
layer=0,
)

result_a = await async_w3.manager.coro_request("not_whitelisted", [])
result_b = await async_w3.manager.coro_request("not_whitelisted", [])

assert result_a != result_b

# -- teardown -- #
async_w3.middleware_onion.remove("result_generator")

0 comments on commit 3f20e8c

Please sign in to comment.