Skip to content

Commit 952a506

Browse files
author
Raphael Krupinski
committed
🔥 Remove unittest usage.
1 parent 1b16c74 commit 952a506

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

‎tests/test_client.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import dataclasses as dc
2-
import unittest
32

43
import fastapi
54
import httpx
65
import pydantic
6+
import pytest
77
import typing_extensions as typing
88
from starlette.responses import JSONResponse
99

@@ -144,24 +144,28 @@ async def login(
144144
client = CatClient(transport=httpx.ASGITransport(app=cats_app))
145145

146146

147-
class TestClient(unittest.IsolatedAsyncioTestCase):
148-
async def test_request(self):
149-
response = await client.cat_list()
150-
self.assertIsInstance(response, list)
151-
self.assertEqual([Cat(id=1, name='Tom')], response)
147+
@pytest.mark.asyncio
148+
async def test_request():
149+
response = await client.cat_list()
150+
assert isinstance(response, list)
151+
assert response == [Cat(id=1, name='Tom')]
152152

153-
cat = await client.cat_get(id=1)
154-
self.assertIsInstance(cat, Cat)
155-
self.assertEqual(Cat(id=1, name='Tom'), cat)
153+
cat = await client.cat_get(id=1)
154+
assert isinstance(cat, Cat)
155+
assert cat == Cat(id=1, name='Tom')
156156

157-
async def test_response_auth(self):
158-
response = await client.login(body=AuthRequest(login='login', password='passwd'))
159157

160-
self.assertEqual("you're in", response.api_key)
158+
@pytest.mark.asyncio
159+
async def test_response_auth():
160+
response = await client.login(body=AuthRequest(login='login', password='passwd'))
161161

162-
async def test_error(self):
163-
try:
164-
await client.cat_get(id=7)
165-
assert False, 'Expected ServerError'
166-
except ServerError as e:
167-
self.assertEqual(e.msg, 'Cat not found')
162+
assert response.api_key == "you're in"
163+
164+
165+
@pytest.mark.asyncio
166+
async def test_error():
167+
try:
168+
await client.cat_get(id=7)
169+
assert False, 'Expected ServerError'
170+
except ServerError as e:
171+
assert e.msg == 'Cat not found'

‎tests/test_response.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import unittest
2-
31
from lapidary.runtime.response import _status_code_matches
42

53

6-
class MatchResponseCodeTest(unittest.TestCase):
7-
def test__status_code_matches(self):
8-
matches = list(_status_code_matches('400'))
9-
self.assertEqual(['400', '4XX', 'default'], matches)
4+
def test__status_code_matches():
5+
matches = list(_status_code_matches('400'))
6+
assert ['400', '4XX', 'default'] == matches

0 commit comments

Comments
 (0)