Skip to content

Commit 58c7fbe

Browse files
authored
Re-run flaky tests when needed (#3604)
1 parent 3dfa34d commit 58c7fbe

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ docs = [
4848
"sphinxcontrib-svg2pdfconverter",
4949
"sphinx-rtd-theme"
5050
]
51-
test = ["packaging", "pytest", "pytest-cov>=4.0", "colorama", "openpyxl"]
51+
test = [
52+
"packaging",
53+
"pytest",
54+
"pytest-cov>=4.0",
55+
"pytest-rerunfailures",
56+
"colorama",
57+
"openpyxl",
58+
]
5259
ci = ["coverage>=7.4", "gcovr>=7.2"]
5360
vtk = ["vtk"]
5461

tests/unit_tests/test_deplete_activation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def model():
4949
("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)']}, 1e-5),
5050
("flux", {'energies': ENERGIES, 'reactions': ['(n,gamma)'], 'nuclides': ['W186', 'H3']}, 1e-2),
5151
])
52+
@pytest.mark.flaky(reruns=1)
5253
def test_activation(run_in_tmpdir, model, reaction_rate_mode, reaction_rate_opts, tolerance):
5354
# Determine (n.gamma) reaction rate using initial run
5455
sp = model.run()

tests/unit_tests/test_stats.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def assert_sample_mean(samples, expected_mean):
1616
assert np.abs(expected_mean - samples.mean()) < 4*std_dev
1717

1818

19+
@pytest.mark.flaky(reruns=1)
1920
def test_discrete():
2021
x = [0.0, 1.0, 10.0]
2122
p = [0.3, 0.2, 0.5]
@@ -104,6 +105,7 @@ def test_clip_discrete():
104105
d.clip(5)
105106

106107

108+
@pytest.mark.flaky(reruns=1)
107109
def test_uniform():
108110
a, b = 10.0, 20.0
109111
d = openmc.stats.Uniform(a, b)
@@ -127,6 +129,7 @@ def test_uniform():
127129
assert_sample_mean(samples, exp_mean)
128130

129131

132+
@pytest.mark.flaky(reruns=1)
130133
def test_powerlaw():
131134
a, b, n = 10.0, 100.0, 2.0
132135
d = openmc.stats.PowerLaw(a, b, n)
@@ -148,6 +151,7 @@ def test_powerlaw():
148151
assert_sample_mean(samples, exp_mean)
149152

150153

154+
@pytest.mark.flaky(reruns=1)
151155
def test_maxwell():
152156
theta = 1.2895e6
153157
d = openmc.stats.Maxwell(theta)
@@ -171,6 +175,7 @@ def test_maxwell():
171175
assert samples_2.mean() != samples.mean()
172176

173177

178+
@pytest.mark.flaky(reruns=1)
174179
def test_watt():
175180
a, b = 0.965e6, 2.29e-6
176181
d = openmc.stats.Watt(a, b)
@@ -194,6 +199,7 @@ def test_watt():
194199
assert_sample_mean(samples, exp_mean)
195200

196201

202+
@pytest.mark.flaky(reruns=1)
197203
def test_tabular():
198204
# test linear-linear sampling
199205
x = np.array([0.0, 5.0, 7.0, 10.0])
@@ -270,6 +276,7 @@ def test_legendre():
270276
d.to_xml_element('distribution')
271277

272278

279+
@pytest.mark.flaky(reruns=1)
273280
def test_mixture():
274281
d1 = openmc.stats.Uniform(0, 5)
275282
d2 = openmc.stats.Uniform(3, 7)
@@ -425,6 +432,7 @@ def test_point():
425432
assert d.xyz == pytest.approx(p)
426433

427434

435+
@pytest.mark.flaky(reruns=1)
428436
def test_normal():
429437
mean = 10.0
430438
std_dev = 2.0
@@ -444,6 +452,7 @@ def test_normal():
444452
assert_sample_mean(samples, mean)
445453

446454

455+
@pytest.mark.flaky(reruns=1)
447456
def test_muir():
448457
mean = 10.0
449458
mass = 5.0
@@ -463,6 +472,7 @@ def test_muir():
463472
assert_sample_mean(samples, mean)
464473

465474

475+
@pytest.mark.flaky(reruns=1)
466476
def test_combine_distributions():
467477
# Combine two discrete (same data as in test_merge_discrete)
468478
x1 = [0.0, 1.0, 10.0]

0 commit comments

Comments
 (0)