* CI(GHActions): Switch to ``setup-miniconda``.
+* Tests: Use ``pytest.fixture``.
+
Version 0.8.0 (2021-09-24)
--------------------------
"""PPU test utilities"""
-
import os
import shutil
import sys
from tempfile import mkdtemp
+import pytest
+
-def setup():
- global tmp_dir
+@pytest.fixture(autouse=True)
+def tmp_dir():
tmp_dir = mkdtemp()
os.chdir(tmp_dir)
-
-
-def teardown():
+ yield
os.chdir(os.sep) # To the root of the FS
shutil.rmtree(tmp_dir, ignore_errors=True)
import subprocess
import sys
-from ppu_tu import setup, teardown, find_in_path # noqa
+
+from ppu_tu import find_in_path
+from ppu_tu import tmp_dir # noqa: F401 tmp_dir imported but unused
test_prog_path = find_in_path('cmp.py')
import os
import subprocess
import sys
-from ppu_tu import setup, teardown, find_in_path # noqa
+
from ppu_tu import create_files, assert_files_exist, assert_files_not_exist
+from ppu_tu import find_in_path
+from ppu_tu import tmp_dir # noqa: F401 tmp_dir imported but unused
test_prog_path = find_in_path('remove-old-files.py')
def test_remove_empty_directory():
- teardown()
- try:
- setup()
- except OSError:
- pass
create_files(['test3', 'test4'], 'subdir')
test3 = os.path.join('subdir', 'test3')
test4 = os.path.join('subdir', 'test4')
import subprocess
import sys
-from ppu_tu import setup, teardown, find_in_path # noqa
+
from ppu_tu import create_files, assert_files_exist, assert_files_not_exist
+from ppu_tu import find_in_path
+from ppu_tu import tmp_dir # noqa: F401 tmp_dir imported but unused
test_prog_path = find_in_path('rm.py')
import os
import subprocess
import sys
-from ppu_tu import setup, teardown, find_in_path # noqa
+
+from ppu_tu import find_in_path
+from ppu_tu import tmp_dir # noqa: F401 tmp_dir imported but unused
test_prog_path = find_in_path('which.py')