Skip to content

Commit f34a6d1

Browse files
Remove helpers and demonstrate tempfile
1 parent 6dd1012 commit f34a6d1

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

tests/test_helpers.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/testing_tests/test_causal_test_suite.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import unittest
22
import os
3+
import tempfile
34
import numpy as np
5+
import shutil
46
import pandas as pd
57
from causal_testing.testing.causal_test_suite import CausalTestSuite
68
from causal_testing.testing.causal_test_case import CausalTestCase
@@ -10,7 +12,6 @@
1012
from causal_testing.testing.estimators import LinearRegressionEstimator, LogisticRegressionEstimator
1113
from causal_testing.specification.causal_specification import CausalSpecification, Scenario
1214
from causal_testing.data_collection.data_collector import ObservationalDataCollector
13-
from tests.test_helpers import create_temp_dir_if_non_existent, remove_temp_dir_if_existent
1415
from causal_testing.specification.causal_dag import CausalDAG
1516

1617

@@ -29,8 +30,8 @@ def setUp(self) -> None:
2930
self.scenario = Scenario({A, C, D})
3031

3132
# 2. Create DAG and dummy data and write to csvs
32-
temp_dir_path = create_temp_dir_if_non_existent()
33-
dag_dot_path = os.path.join(temp_dir_path, "dag.dot")
33+
self.temp_dir_path = tempfile.mkdtemp()
34+
dag_dot_path = os.path.join(self.temp_dir_path, "dag.dot")
3435
dag_dot = """digraph G { A -> C; D -> A; D -> C}"""
3536
with open(dag_dot_path, "w") as file:
3637
file.write(dag_dot)
@@ -64,6 +65,9 @@ def setUp(self) -> None:
6465

6566
self.data_collector = ObservationalDataCollector(self.scenario, self.df)
6667

68+
def tearDown(self) -> None:
69+
shutil.rmtree(self.temp_dir_path)
70+
6771
def test_adding_test_object(self):
6872
"test an object can be added to the test_suite using the add_test_object function"
6973
test_suite = CausalTestSuite()

0 commit comments

Comments
 (0)