Skip to content

🔥 Remove use of fixture factories in unittests #74

@demberto

Description

@demberto

Fixtures like these make the function less readable, have no actual benefit over normal functions (as in, they don't need session scope etc.)

@pytest.fixture
def load_channel(get_model: ModelFixture):
def wrapper(preset: str, type: type[Channel] = Channel):
return get_model(f"channels/{preset}", type)
return wrapper
@pytest.fixture
def load_instrument(load_channel: ModelFixture):
def wrapper(preset: str):
return load_channel(preset, Instrument)
return wrapper
@pytest.fixture
def load_layer(load_channel: Any):
def wrapper(preset: str):
return load_channel(preset, Layer)
return wrapper
@pytest.fixture
def load_sampler(load_channel: Any):
def wrapper(preset: str):
return load_channel(preset, Sampler)
return wrapper

Additional type-hinting code is required as well to pass them as arguments to a test function:

ChannelFixture = Callable[[str], Channel]
InstrumentFixture = Callable[[str], Instrument]
LayerFixture = Callable[[str], Layer]
SamplerFixture = Callable[[str], Sampler]

Metadata

Metadata

Assignees

Labels

testingUnit tests and pytest configuration

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions