mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Upgrade pytest to 3.6.0
https://github.com/pytest-dev/pytest/issues/1875 made it impossible to declare a function as a fixture multiple times, which we were doing across different modules. The fix was to move our @pytest.fixture calls into decorators in the tests/fixtures.py module.
This commit is contained in:
parent
16398641d9
commit
969771770f
5 changed files with 15 additions and 17 deletions
2
setup.py
2
setup.py
|
|
@ -48,7 +48,7 @@ setup(
|
||||||
''',
|
''',
|
||||||
setup_requires=['pytest-runner'],
|
setup_requires=['pytest-runner'],
|
||||||
tests_require=[
|
tests_require=[
|
||||||
'pytest==3.2.1',
|
'pytest==3.6.0',
|
||||||
'aiohttp==2.3.2',
|
'aiohttp==2.3.2',
|
||||||
'beautifulsoup4==4.6.0',
|
'beautifulsoup4==4.6.0',
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from datasette.app import Datasette
|
from datasette.app import Datasette
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
|
import pytest
|
||||||
import random
|
import random
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -9,6 +10,7 @@ import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='session')
|
||||||
def app_client(sql_time_limit_ms=None, max_returned_rows=None, config=None):
|
def app_client(sql_time_limit_ms=None, max_returned_rows=None, config=None):
|
||||||
with tempfile.TemporaryDirectory() as tmpdir:
|
with tempfile.TemporaryDirectory() as tmpdir:
|
||||||
filepath = os.path.join(tmpdir, 'test_tables.db')
|
filepath = os.path.join(tmpdir, 'test_tables.db')
|
||||||
|
|
@ -39,11 +41,13 @@ def app_client(sql_time_limit_ms=None, max_returned_rows=None, config=None):
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='session')
|
||||||
def app_client_shorter_time_limit():
|
def app_client_shorter_time_limit():
|
||||||
yield from app_client(20)
|
yield from app_client(20)
|
||||||
|
|
||||||
|
|
||||||
def app_client_returend_rows_matches_page_size():
|
@pytest.fixture(scope='session')
|
||||||
|
def app_client_returned_rows_matches_page_size():
|
||||||
yield from app_client(max_returned_rows=50)
|
yield from app_client(max_returned_rows=50)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from .fixtures import (
|
from .fixtures import ( # noqa
|
||||||
app_client,
|
app_client,
|
||||||
app_client_shorter_time_limit,
|
app_client_shorter_time_limit,
|
||||||
app_client_returend_rows_matches_page_size,
|
app_client_returned_rows_matches_page_size,
|
||||||
generate_compound_rows,
|
generate_compound_rows,
|
||||||
generate_sortable_rows,
|
generate_sortable_rows,
|
||||||
METADATA,
|
METADATA,
|
||||||
|
|
@ -9,10 +9,6 @@ from .fixtures import (
|
||||||
import pytest
|
import pytest
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
pytest.fixture(scope='session')(app_client)
|
|
||||||
pytest.fixture(scope='session')(app_client_shorter_time_limit)
|
|
||||||
pytest.fixture(scope='session')(app_client_returend_rows_matches_page_size)
|
|
||||||
|
|
||||||
|
|
||||||
def test_homepage(app_client):
|
def test_homepage(app_client):
|
||||||
_, response = app_client.get('/.json')
|
_, response = app_client.get('/.json')
|
||||||
|
|
@ -936,11 +932,11 @@ def test_config_json(app_client):
|
||||||
} == response.json
|
} == response.json
|
||||||
|
|
||||||
|
|
||||||
def test_page_size_matching_max_returned_rows(app_client_returend_rows_matches_page_size):
|
def test_page_size_matching_max_returned_rows(app_client_returned_rows_matches_page_size):
|
||||||
fetched = []
|
fetched = []
|
||||||
path = '/test_tables/no_primary_key.json'
|
path = '/test_tables/no_primary_key.json'
|
||||||
while path:
|
while path:
|
||||||
response = app_client_returend_rows_matches_page_size.get(
|
response = app_client_returned_rows_matches_page_size.get(
|
||||||
path, gather_request=False
|
path, gather_request=False
|
||||||
)
|
)
|
||||||
fetched.extend(response.json['rows'])
|
fetched.extend(response.json['rows'])
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
from bs4 import BeautifulSoup as Soup
|
from bs4 import BeautifulSoup as Soup
|
||||||
from .fixtures import app_client, app_client_shorter_time_limit
|
from .fixtures import ( # noqa
|
||||||
|
app_client,
|
||||||
|
app_client_shorter_time_limit,
|
||||||
|
)
|
||||||
import pytest
|
import pytest
|
||||||
import re
|
import re
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
pytest.fixture(scope='session')(app_client)
|
|
||||||
pytest.fixture(scope='session')(app_client_shorter_time_limit)
|
|
||||||
|
|
||||||
|
|
||||||
def test_homepage(app_client):
|
def test_homepage(app_client):
|
||||||
response = app_client.get('/', gather_request=False)
|
response = app_client.get('/', gather_request=False)
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,9 @@
|
||||||
from bs4 import BeautifulSoup as Soup
|
from bs4 import BeautifulSoup as Soup
|
||||||
from .fixtures import (
|
from .fixtures import ( # noqa
|
||||||
app_client,
|
app_client,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
pytest.fixture(scope='session')(app_client)
|
|
||||||
|
|
||||||
|
|
||||||
def test_plugins_dir_plugin(app_client):
|
def test_plugins_dir_plugin(app_client):
|
||||||
response = app_client.get(
|
response = app_client.get(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue