Skip to content

Commit 6123999

Browse files
author
AndrewC19
committed
Added mediator to test
1 parent ea8b3ab commit 6123999

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/specification_tests/test_metamorphic_relations.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,16 @@ def test_should_cause_metamorphic_relation_missing_relationship(self):
121121

122122
def test_all_metamorphic_relations_implied_by_dag(self):
123123
dag = CausalDAG(self.dag_dot_path)
124+
dag.add_edge('Z', 'Y') # Add a direct path from Z to Y so M becomes a mediator
124125
metamorphic_relations = generate_metamorphic_relations(dag)
125126
should_cause_relations = [mr for mr in metamorphic_relations if isinstance(mr, ShouldCause)]
126127
should_not_cause_relations = [mr for mr in metamorphic_relations if isinstance(mr, ShouldNotCause)]
127128

128129
# Check all ShouldCause relations are present and no extra
129130
expected_should_cause_relations = [ShouldCause('X1', 'Z', [], dag),
130131
ShouldCause('Z', 'M', [], dag),
131-
ShouldCause('M', 'Y', [], dag),
132+
ShouldCause('M', 'Y', ['Z'], dag),
133+
ShouldCause('Z', 'Y', ['M'], dag),
132134
ShouldCause('X2', 'Z', [], dag),
133135
ShouldCause('X3', 'M', [], dag)]
134136

@@ -142,12 +144,11 @@ def test_all_metamorphic_relations_implied_by_dag(self):
142144
expected_should_not_cause_relations = [ShouldNotCause('X1', 'X2', [], dag),
143145
ShouldNotCause('X1', 'X3', [], dag),
144146
ShouldNotCause('X1', 'M', ['Z'], dag),
145-
ShouldNotCause('X1', 'Y', ['M'], dag),
147+
ShouldNotCause('X1', 'Y', ['Z'], dag),
146148
ShouldNotCause('X2', 'X3', [], dag),
147149
ShouldNotCause('X2', 'M', ['Z'], dag),
148-
ShouldNotCause('X2', 'Y', ['M'], dag),
149-
ShouldNotCause('X3', 'Y', ['M'], dag),
150-
ShouldNotCause('Z', 'Y', ['M'], dag),
150+
ShouldNotCause('X2', 'Y', ['Z'], dag),
151+
ShouldNotCause('X3', 'Y', ['M', 'Z'], dag),
151152
ShouldNotCause('Z', 'X3', [], dag)]
152153

153154
extra_snc_relations = [sncr for sncr in should_not_cause_relations if sncr

0 commit comments

Comments
 (0)