1
1
import unittest
2
2
import os
3
+ import tempfile
3
4
import numpy as np
5
+ import shutil
4
6
import pandas as pd
5
7
from causal_testing .testing .causal_test_suite import CausalTestSuite
6
8
from causal_testing .testing .causal_test_case import CausalTestCase
10
12
from causal_testing .testing .estimators import LinearRegressionEstimator , LogisticRegressionEstimator
11
13
from causal_testing .specification .causal_specification import CausalSpecification , Scenario
12
14
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
14
15
from causal_testing .specification .causal_dag import CausalDAG
15
16
16
17
@@ -29,8 +30,8 @@ def setUp(self) -> None:
29
30
self .scenario = Scenario ({A , C , D })
30
31
31
32
# 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" )
34
35
dag_dot = """digraph G { A -> C; D -> A; D -> C}"""
35
36
with open (dag_dot_path , "w" ) as file :
36
37
file .write (dag_dot )
@@ -64,6 +65,9 @@ def setUp(self) -> None:
64
65
65
66
self .data_collector = ObservationalDataCollector (self .scenario , self .df )
66
67
68
+ def tearDown (self ) -> None :
69
+ shutil .rmtree (self .temp_dir_path )
70
+
67
71
def test_adding_test_object (self ):
68
72
"test an object can be added to the test_suite using the add_test_object function"
69
73
test_suite = CausalTestSuite ()
0 commit comments