Extract common fixtures in conftest.py
This commit is contained in:
parent
dad360255b
commit
6700b4b8e0
2 changed files with 21 additions and 16 deletions
20
python_apps/airtime_analyzer/tests/conftest.py
Normal file
20
python_apps/airtime_analyzer/tests/conftest.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
import pytest
|
||||
import os
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
AUDIO_FILE = "tests/test_data/44100Hz-16bit-mono.mp3"
|
||||
AUDIO_FILENAME = os.path.basename(AUDIO_FILE)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def dest_dir():
|
||||
with tempfile.TemporaryDirectory(prefix="dest") as tmpdir:
|
||||
yield tmpdir
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def src_dir():
|
||||
with tempfile.TemporaryDirectory(prefix="src") as tmpdir:
|
||||
shutil.copy(AUDIO_FILE, tmpdir)
|
||||
yield tmpdir
|
|
@ -6,9 +6,7 @@ import time
|
|||
import mock
|
||||
import pytest
|
||||
from airtime_analyzer.filemover_analyzer import FileMoverAnalyzer
|
||||
|
||||
AUDIO_FILE = "tests/test_data/44100Hz-16bit-mono.mp3"
|
||||
AUDIO_FILENAME = os.path.basename(AUDIO_FILE)
|
||||
from .conftest import AUDIO_FILENAME
|
||||
|
||||
|
||||
def test_dont_use_analyze():
|
||||
|
@ -30,19 +28,6 @@ def test_move_wrong_params(params, exception):
|
|||
FileMoverAnalyzer.move(*params)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def dest_dir():
|
||||
with tempfile.TemporaryDirectory(prefix="dest") as tmpdir:
|
||||
yield tmpdir
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def src_dir():
|
||||
with tempfile.TemporaryDirectory(prefix="src") as tmpdir:
|
||||
shutil.copy(AUDIO_FILE, tmpdir)
|
||||
yield tmpdir
|
||||
|
||||
|
||||
def test_basic(src_dir, dest_dir):
|
||||
FileMoverAnalyzer.move(
|
||||
os.path.join(src_dir, AUDIO_FILENAME),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue