class Fixture:
def __init__(self, mongo_client: MongoDB) -> None:
self.mongo_client = mongo_client
@fixture
def create(self):
pass
class TestService(Fixture):
def test_something():
print('start test method')
fixture 클래스에서 dependency injection을 해주고 fixture 클래스를 상속 받아서 데이터를 생성하려고 했다. __init__
이 있으면 경고가 떴다.
의존성 주입을 하지 않고 인스턴스를 fixture로 만들어서 사용하기로 함.
@fixture(autouse=True)
def mongo_client():
mongo_db = MongoDB()
return mongo_db.mongo_client
class ChargerFeeFixture:
# def __init__(self, mongo_client: MongoDB) -> None:
# self.mongo_client = mongo_client
@fixture(autouse=True)
def create_charger_fee(self, mongo_client):
self.mongo_client = mongo_client