Skip to content

Commit 9baf98d

Browse files
Update file opens to with open(...)
1 parent ca926aa commit 9baf98d

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

tests/testing_tests/test_causal_test_engine.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ def setUp(self) -> None:
2626
temp_dir_path = create_temp_dir_if_non_existent()
2727
dag_dot_path = os.path.join(temp_dir_path, "dag.dot")
2828
dag_dot = """digraph G { A -> C; D -> A; D -> C}"""
29-
f = open(dag_dot_path, "w")
30-
f.write(dag_dot)
31-
f.close()
29+
with open(dag_dot_path, "w") as file:
30+
file.write(dag_dot)
3231
self.causal_dag = CausalDAG(dag_dot_path)
3332

3433
# 2. Create Scenario and Causal Specification

tests/testing_tests/test_causal_test_suite.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ def setUp(self) -> None:
3333
temp_dir_path = create_temp_dir_if_non_existent()
3434
dag_dot_path = os.path.join(temp_dir_path, "dag.dot")
3535
dag_dot = """digraph G { A -> C; D -> A; D -> C}"""
36-
f = open(dag_dot_path, "w")
37-
f.write(dag_dot)
38-
f.close()
36+
with open(dag_dot_path, "w") as file:
37+
file.write(dag_dot)
3938

4039
np.random.seed(1)
4140
df = pd.DataFrame({"D": list(np.random.normal(60, 10, 1000))}) # D = exogenous

0 commit comments

Comments
 (0)