Skip to content

Commit dc6bd8b

Browse files
committed
Improve tests
These are small improvement detected during code review.
1 parent d3194bb commit dc6bd8b

4 files changed

Lines changed: 48 additions & 7 deletions

File tree

libs/pyext/test/py_u_TestAttributeAddDelete.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def test_suite_variable_add_delete_and_sort():
135135
suite.add_variable({})
136136
assert len(list(suite.variables)) == 0
137137

138-
with pytest.raises((TypeError, RuntimeError)):
138+
with pytest.raises(RuntimeError):
139139
suite.add_variable(
140140
{"name": "fred", "name2": 14, "name3": list("123"), "name4": 12}
141141
)
@@ -560,6 +560,13 @@ def test_task_autocancel_variants():
560560
assert t5.get_autocancel() is not None
561561

562562

563+
def test_family_autocancel_variants():
564+
f5 = ecflow.Family("f5")
565+
assert f5.get_autocancel() is None
566+
f5.add_autocancel(ecflow.Autocancel(1, 10, True)) # hour,minutes,relative
567+
assert f5.get_autocancel() is not None
568+
569+
563570
def test_family_autoarchive_variants():
564571
f1 = ecflow.Family("f1")
565572
assert f1.get_autoarchive() is None

libs/pyext/test/py_u_TestAutoAddExtern.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,32 @@ def test_auto_add_extern_for_task_inlimit_with_suite_path(defs):
103103
suite.add_family("f3").add_task("t1").add_inlimit("hpcd", "/obs/limits")
104104
suite.add_family("f4").add_task("t2").add_inlimit("c1a", "/limits")
105105
_expect_check_fails_then_passes(defs)
106+
107+
108+
def test_auto_add_extern_incrementally_across_multiple_check_cycles(defs):
109+
"""Repeatedly call check()/auto_add_externs(True) on the same, growing Defs,
110+
to verify auto_add_externs behaves correctly across multiple incremental
111+
invocations rather than just once against a fully pre-built Defs."""
112+
suite = defs.add_suite("ext")
113+
114+
f1 = suite.add_family("f1")
115+
f1.add_task("t").add_trigger("/a/b/c/d == complete")
116+
_expect_check_fails_then_passes(defs)
117+
f1.add_task("t1").add_trigger("/a/b/c/d/e:event == set")
118+
_expect_check_fails_then_passes(defs)
119+
f1.add_task("t2").add_trigger("/a/b/c/d/x:event")
120+
_expect_check_fails_then_passes(defs)
121+
f1.add_task("t3").add_trigger("/a/b/c/d/y:meter le 30")
122+
_expect_check_fails_then_passes(defs)
123+
f1.add_task("t4").add_trigger("/a/b/c/d/z<flag>late")
124+
_expect_check_fails_then_passes(defs)
125+
126+
f2 = suite.add_family("f2")
127+
f2.add_inlimit("hpcd", "limits")
128+
_expect_check_fails_then_passes(defs)
129+
f2.add_task("t").add_inlimit("sg1", "/suiteName")
130+
_expect_check_fails_then_passes(defs)
131+
f2.add_task("t1").add_inlimit("hpcd", "/obs/limits")
132+
_expect_check_fails_then_passes(defs)
133+
f2.add_task("t2").add_inlimit("c1a", "/limits")
134+
_expect_check_fails_then_passes(defs)

libs/pyext/test/py_u_TestDefs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def test_suite_construction_and_variables():
9494
suite.add_variable("ECF_URL", "publications/manuals/sms")
9595
suite.add_limit(Limit("limitName", 10))
9696
suite.add_limit("limitName_2", 10)
97+
assert not suite.begun(), "Suite should not have begun"
9798

9899
clock = Clock(1, 1, 2010, False)
99100
clock.set_gain(1, 10, True)

libs/pyext/test/py_u_TestTutorial.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,16 @@ def _compile_tutorial_text(text):
6161

6262

6363
def _remove_tutorial_artifacts():
64-
for pattern in ("test_tutorial_def_*.def", "py_u_test_tutorial_*.def"):
65-
for path in pathlib.Path.cwd().glob(pattern):
66-
try:
67-
path.unlink()
68-
except OSError:
69-
pass
64+
# Scoped to the current process's own artifacts only (names embed os.getpid()),
65+
# so concurrent invocations from the same working directory don't delete each
66+
# other's in-progress files.
67+
pid = os.getpid()
68+
for pattern in (f"test_tutorial_def_{pid}.def", f"py_u_test_tutorial_{pid}.def"):
69+
path = pathlib.Path.cwd() / pattern
70+
try:
71+
path.unlink()
72+
except OSError:
73+
pass
7074

7175

7276
def do_tear_down():

0 commit comments

Comments
 (0)