Skip to content

Commit 18566c0

Browse files
committed
Dedupe
Signed-off-by: Anuraag Agrawal <[email protected]>
1 parent 634cf82 commit 18566c0

File tree

1 file changed

+9
-32
lines changed

1 file changed

+9
-32
lines changed

test/test_lifespan.py

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717
from .haberdasher_pb2 import Hat, Size
1818

1919

20-
@pytest.mark.asyncio
21-
async def test_lifespan() -> None:
22-
class CountingHaberdasher(Haberdasher):
23-
def __init__(self, counter: Counter) -> None:
24-
self._counter = counter
20+
class CountingHaberdasher(Haberdasher):
21+
def __init__(self, counter: Counter) -> None:
22+
self._counter = counter
23+
24+
async def make_hat(self, request, ctx):
25+
self._counter["requests"] += 1
26+
return Hat(size=request.inches, color="blue")
2527

26-
async def make_hat(self, request, ctx):
27-
self._counter["requests"] += 1
28-
return Hat(size=request.inches, color="blue")
2928

29+
@pytest.mark.asyncio
30+
async def test_lifespan() -> None:
3031
final_count = None
3132

3233
async def counting_haberdasher():
@@ -69,14 +70,6 @@ async def counting_haberdasher():
6970

7071
@pytest.mark.asyncio
7172
async def test_lifespan_startup_error() -> None:
72-
class CountingHaberdasher(Haberdasher):
73-
def __init__(self, counter: Counter) -> None:
74-
self._counter = counter
75-
76-
async def make_hat(self, request, ctx):
77-
self._counter["requests"] += 1
78-
return Hat(size=request.inches, color="blue")
79-
8073
final_count = None
8174

8275
async def counting_haberdasher():
@@ -112,14 +105,6 @@ async def counting_haberdasher():
112105

113106
@pytest.mark.asyncio
114107
async def test_lifespan_shutdown_error() -> None:
115-
class CountingHaberdasher(Haberdasher):
116-
def __init__(self, counter: Counter) -> None:
117-
self._counter = counter
118-
119-
async def make_hat(self, request, ctx):
120-
self._counter["requests"] += 1
121-
return Hat(size=request.inches, color="blue")
122-
123108
async def counting_haberdasher():
124109
counter = Counter()
125110
try:
@@ -167,14 +152,6 @@ async def counting_haberdasher():
167152

168153
@pytest.mark.asyncio
169154
async def test_lifespan_not_supported() -> None:
170-
class CountingHaberdasher(Haberdasher):
171-
def __init__(self, counter: Counter) -> None:
172-
self._counter = counter
173-
174-
async def make_hat(self, request, ctx):
175-
self._counter["requests"] += 1
176-
return Hat(size=request.inches, color="blue")
177-
178155
final_count = None
179156

180157
async def counting_haberdasher():

0 commit comments

Comments
 (0)