Skip to content

Commit

Permalink
Workaround for cwd bug
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jul 5, 2019
1 parent e06e083 commit 109c2e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import os
import pytest


def pytest_configure(config):
import sys

Expand All @@ -22,3 +26,14 @@ 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])))


@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)
2 changes: 1 addition & 1 deletion tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_plugins_asgi_wrapper(app_client):
assert "fixtures" == response.headers["x-databases"]


def test_plugins_extra_template_vars():
def test_plugins_extra_template_vars(restore_working_directory):
for client in make_app_client(
template_dir=str(pathlib.Path(__file__).parent / "test_templates")
):
Expand Down

0 comments on commit 109c2e2

Please sign in to comment.