Skip to content

Commit 07562ef

Browse files
committed
Tests: Move changing directory for loading model to fixture
1 parent 96f9351 commit 07562ef

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import pytest
77

88

9+
@pytest.fixture
10+
def change_to_test_dir(monkeypatch):
11+
monkeypatch.chdir(Path(__file__).parent) # Where model is
12+
913
def get_piper_model_path():
1014
""" Get Piper model path from environment or use default. """
1115
model_name = os.environ.get('PIPER_MODEL', 'en_US-ryan-low.onnx')

tests/test_grammar.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
class TestGrammar:
1212

1313
@pytest.fixture(autouse=True)
14-
def setup(self, monkeypatch, audio_generator):
15-
monkeypatch.chdir(Path(__file__).parent) # Where model is
14+
def setup(self, change_to_test_dir, audio_generator):
1615
self.compiler = Compiler()
1716
self.decoder = self.compiler.init_decoder()
1817
self.audio_generator = audio_generator

tests/test_plain_dictation.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
class TestPlainDictation:
1212

1313
@pytest.fixture(autouse=True)
14-
def setup(self, monkeypatch):
15-
monkeypatch.chdir(Path(__file__).parent) # Where model is
14+
def setup(self, change_to_test_dir):
1615
self.recognizer = PlainDictationRecognizer()
1716

1817
def test_initialization(self):

0 commit comments

Comments
 (0)