Skip to content

Commit 992b8e5

Browse files
committed
fix: add a pytest fixture to prevent make test error
Signed-off-by: Abdulaziz Memesh <abdulazizmemesh@gmail.com>
1 parent ed10dad commit 992b8e5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"""Common fixtures."""
1616
import os
1717
import pathlib
18+
import shutil
1819
import random
1920
import string
2021
import sys
@@ -38,6 +39,26 @@
3839
TEST_CONFIG: dict = {}
3940

4041

42+
@pytest.fixture(scope='session', autouse=True)
43+
def clean_tmp():
44+
"""Remove Trestle workspace in /tmp if there's one"""
45+
if os.name == 'posix':
46+
curr_path = os.getcwd()
47+
os.chdir("/tmp")
48+
try:
49+
shutil.rmtree(".trestle")
50+
shutil.rmtree("dist")
51+
shutil.rmtree("catalogs")
52+
shutil.rmtree("profiles")
53+
shutil.rmtree("component-definitions")
54+
shutil.rmtree("system-security-plans")
55+
shutil.rmtree("assessment-plans")
56+
shutil.rmtree("assessment-results")
57+
shutil.rmtree("plan-of-action-and-milestones")
58+
finally:
59+
os.chdir(curr_path)
60+
61+
4162
@pytest.fixture(scope='function')
4263
def rand_str():
4364
"""Return a random string."""

0 commit comments

Comments
 (0)