Fix pytest working dir in Pycharm (#199)

My unit tests assume cwd = /, in order to locate wav files.
But Pycharm uses the wrong working dir whenever you "rerun failed tests" or "run tests in file".
This runs `chdir(correct dir)`.
pull/357/head
nyanpasu64 2019-02-16 03:09:56 -08:00 zatwierdzone przez GitHub
rodzic 18e13ea9d1
commit 2aaf1452ac
1 zmienionych plików z 6 dodań i 0 usunięć

Wyświetl plik

@ -6,6 +6,7 @@ Integration tests found in:
import os
import subprocess
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
@ -14,6 +15,11 @@ if TYPE_CHECKING:
import pytest_mock
# Pycharm sets cwd to /tests/.
# To ensure tests can find WAV files (based on /), jump from /tests/conftest.py to /.
os.chdir(Path(__file__).parent.parent)
@pytest.fixture
def Popen(mocker: "pytest_mock.MockFixture"):
real_Popen = subprocess.Popen