Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Remove use of fixture factories in unittests #74

Closed
demberto opened this issue Oct 8, 2022 · 0 comments
Closed

🔥 Remove use of fixture factories in unittests #74

demberto opened this issue Oct 8, 2022 · 0 comments
Assignees
Labels
testing Unit tests and pytest configuration
Milestone

Comments

@demberto
Copy link
Owner

demberto commented Oct 8, 2022

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]

@demberto demberto added question Further information is requested testing Unit tests and pytest configuration labels Oct 8, 2022
@demberto demberto self-assigned this Nov 19, 2022
@demberto demberto removed the question Further information is requested label Nov 19, 2022
@demberto demberto added this to the PyFLP 2.0.0 milestone Nov 19, 2022
@demberto demberto changed the title ❓ Replace fixtures which return wrappers with functions 🔥 Remove use of fixture factories in unittests Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Unit tests and pytest configuration
Projects
None yet
Development

No branches or pull requests

1 participant