2019-07-06 00:05:56 +00:00
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2019-05-02 05:10:23 +00:00
|
|
|
def pytest_configure(config):
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys._called_from_test = True
|
|
|
|
|
|
|
|
|
|
|
|
def pytest_unconfigure(config):
|
|
|
|
import sys
|
|
|
|
|
|
|
|
del sys._called_from_test
|
2019-05-04 02:15:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
def pytest_collection_modifyitems(items):
|
2019-05-11 21:45:59 +00:00
|
|
|
# Ensure test_black.py and test_inspect.py run first before any asyncio code kicks in
|
|
|
|
move_to_front(items, "test_black")
|
|
|
|
move_to_front(items, "test_inspect_cli")
|
2019-05-11 22:03:52 +00:00
|
|
|
move_to_front(items, "test_inspect_cli_writes_to_file")
|
2019-05-11 23:22:55 +00:00
|
|
|
move_to_front(items, "test_spatialite_error_if_attempt_to_open_spatialite")
|
2020-01-29 22:46:43 +00:00
|
|
|
move_to_front(items, "test_package")
|
|
|
|
move_to_front(items, "test_package_with_port")
|
2019-05-11 21:45:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
def move_to_front(items, test_name):
|
|
|
|
test = [fn for fn in items if fn.name == test_name]
|
|
|
|
if test:
|
|
|
|
items.insert(0, items.pop(items.index(test[0])))
|
2019-07-06 00:05:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def restore_working_directory(tmpdir, request):
|
|
|
|
previous_cwd = os.getcwd()
|
|
|
|
tmpdir.chdir()
|
|
|
|
|
|
|
|
def return_to_previous():
|
|
|
|
os.chdir(previous_cwd)
|
|
|
|
|
|
|
|
request.addfinalizer(return_to_previous)
|