Skip to content

Commit

Permalink
Merge pull request #168 from AI-SDC/deleting_test_folders
Browse files Browse the repository at this point in the history
Delete folders after tests
  • Loading branch information
jim-smith authored Oct 9, 2023
2 parents eb1a405 + 6580386 commit e96f64f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/test_stata_interface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""This module contains unit tests for the stata interface."""

import os
import shutil

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -33,6 +34,15 @@ def data() -> pd.DataFrame:
return data


def clean_up(name):
"""Removes unwanted files or directory."""
if os.path.exists(name):
if os.path.isfile(name):
os.remove(name)
elif os.path.isdir(name):
shutil.rmtree(name)


def dummy_acrohandler(
data, command, varlist, exclusion, exp, weights, options
): # pylint:disable=too-many-arguments
Expand Down Expand Up @@ -736,3 +746,10 @@ def test_stata_unknown(data):
)
correct = "acro command not recognised: foo"
assert ret == correct, f"got:\n{ret}\nexpected:\n{correct}\n"


def test_cleanup():
"""Gets rid of files created during tests."""
names = ["test_outputs", "test_add_to_acro", "sdc_results", "RES_PYTEST"]
for name in names:
clean_up(name)

0 comments on commit e96f64f

Please sign in to comment.