Skip to content

Commit 188dd5d

Browse files
committed
work around Pytest-related flakiness
1 parent 8ab63bb commit 188dd5d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

Diff for: tests/test_stl_bind_map.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
import sys
3+
import platform
34

45
import test_bind_map_ext as t
56

@@ -38,8 +39,14 @@ def test_map_string_double(capfd):
3839

3940
with pytest.raises(TypeError):
4041
mm2.update({"a" : "b"})
41-
captured = capfd.readouterr()
42-
assert captured.err.strip() == "nanobind: implicit conversion from type 'dict' to type 'test_bind_map_ext.MapStringDouble' failed!"
42+
captured = capfd.readouterr().err.strip()
43+
ref = "nanobind: implicit conversion from type 'dict' to type 'test_bind_map_ext.MapStringDouble' failed!"
44+
45+
# Work around Pytest-related flakiness (https://github.com/pytest-dev/pytest/issues/10843)
46+
if platform.system() == 'Windows':
47+
assert captured == ref or captured == ''
48+
else:
49+
assert captured == ref
4350

4451
mm2.update({"a" : 2.5})
4552
assert len(mm2) == 1

Diff for: tests/test_stl_bind_vector.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import platform
23

34
import test_bind_vector_ext as t
45

@@ -43,8 +44,14 @@ def test01_vector_int(capfd):
4344
with pytest.raises(TypeError):
4445
v_int2.extend([8, "a"])
4546

46-
captured = capfd.readouterr()
47-
assert captured.err.strip() == "nanobind: implicit conversion from type 'list' to type 'test_bind_vector_ext.VectorInt' failed!"
47+
captured = capfd.readouterr().err.strip()
48+
ref = "nanobind: implicit conversion from type 'list' to type 'test_bind_vector_ext.VectorInt' failed!"
49+
50+
# Work around Pytest-related flakiness (https://github.com/pytest-dev/pytest/issues/10843)
51+
if platform.system() == 'Windows':
52+
assert captured == ref or captured == ''
53+
else:
54+
assert captured == ref
4855

4956
assert v_int2 == t.VectorInt([0, 99, 2, 3, 4, 5, 6, 7])
5057

0 commit comments

Comments
 (0)