Updated how we use pytest fixtures to avoid new warning

This commit is contained in:
Simon Willison 2018-11-19 18:39:09 -08:00
commit a799ac6232
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
2 changed files with 17 additions and 12 deletions

View file

@ -23,8 +23,7 @@ class TestClient:
)
@pytest.fixture(scope="session")
def app_client(
def make_app_client(
sql_time_limit_ms=None,
max_returned_rows=None,
cors=False,
@ -61,38 +60,43 @@ def app_client(
yield client
@pytest.fixture(scope="session")
def app_client(**kwargs):
yield from make_app_client(**kwargs)
@pytest.fixture(scope='session')
def app_client_shorter_time_limit():
yield from app_client(20)
yield from make_app_client(20)
@pytest.fixture(scope='session')
def app_client_returned_rows_matches_page_size():
yield from app_client(max_returned_rows=50)
yield from make_app_client(max_returned_rows=50)
@pytest.fixture(scope='session')
def app_client_larger_cache_size():
yield from app_client(config={
yield from make_app_client(config={
'cache_size_kb': 2500,
})
@pytest.fixture(scope='session')
def app_client_csv_max_mb_one():
yield from app_client(config={
yield from make_app_client(config={
'max_csv_mb': 1,
})
@pytest.fixture(scope="session")
def app_client_with_dot():
yield from app_client(filename="fixtures.dot.db")
yield from make_app_client(filename="fixtures.dot.db")
@pytest.fixture(scope='session')
def app_client_with_cors():
yield from app_client(cors=True)
yield from make_app_client(cors=True)
def generate_compound_rows(num):

View file

@ -6,6 +6,7 @@ from .fixtures import ( # noqa
app_client_with_dot,
generate_compound_rows,
generate_sortable_rows,
make_app_client,
METADATA,
)
import pytest
@ -435,7 +436,7 @@ def test_invalid_custom_sql(app_client):
def test_allow_sql_off():
for client in app_client(config={
for client in make_app_client(config={
'allow_sql': False,
}):
assert 400 == client.get(
@ -1179,7 +1180,7 @@ def test_suggested_facets(app_client):
def test_allow_facet_off():
for client in app_client(config={
for client in make_app_client(config={
'allow_facet': False,
}):
assert 400 == client.get(
@ -1192,7 +1193,7 @@ def test_allow_facet_off():
def test_suggest_facets_off():
for client in app_client(config={
for client in make_app_client(config={
'suggest_facets': False,
}):
# Now suggested_facets should be []
@ -1304,7 +1305,7 @@ def test_config_cache_size(app_client_larger_cache_size):
def test_config_force_https_urls():
for client in app_client(config={"force_https_urls": True}):
for client in make_app_client(config={"force_https_urls": True}):
response = client.get("/fixtures/facetable.json?_size=3&_facet=state")
assert response.json["next_url"].startswith("https://")
assert response.json["facet_results"]["state"]["results"][0][