We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
A lot of Datasette tests look like this:
datasette/tests/test_api.py
Lines 438 to 444 in b65d977
The loop here isn't actually expected to loop - it's there because the make_app_client function yields a value and then cleans it up afterwards.
make_app_client
This pattern works, but it is a little confusing. It would be nice to replace it with something less strange looking.
The answer may be to switch to the "factories as fixtures" pattern described here: https://docs.pytest.org/en/latest/fixture.html#factories-as-fixtures
In particular some variant of this example:
@pytest.fixture def make_customer_record(): created_records = [] def _make_customer_record(name): record = models.Customer(name=name, orders=[]) created_records.append(record) return record yield _make_customer_record for record in created_records: record.destroy() def test_customer_records(make_customer_record): customer_1 = make_customer_record("Lisa") customer_2 = make_customer_record("Mike") customer_3 = make_customer_record("Meredith")
The text was updated successfully, but these errors were encountered:
This is a pattern I like:
with make_app_client( template_dir=str(pathlib.Path(__file__).parent / "test_templates") ) as client: response = client.get("/-/metadata") assert response.status == 200
Sorry, something went wrong.
abc7339
Release Datasette 0.44
b906030
Refs #395, #519, #576, #699, #706, #774, #777, #781, #784, #788, #790, #797, #798, #800, #802, #804, #819, #822, #825, #826, #827, #828, #829, #830, #833, #836, #837, #839 Closes #806.
No branches or pull requests
A lot of Datasette tests look like this:
datasette/tests/test_api.py
Lines 438 to 444 in b65d977
The loop here isn't actually expected to loop - it's there because the
make_app_client
function yields a value and then cleans it up afterwards.This pattern works, but it is a little confusing. It would be nice to replace it with something less strange looking.
The answer may be to switch to the "factories as fixtures" pattern described here: https://docs.pytest.org/en/latest/fixture.html#factories-as-fixtures
In particular some variant of this example:
The text was updated successfully, but these errors were encountered: