Skip to content

Commit 9dbd9f1

Browse files
committed
Rename test_virtual_base_at_offset_0() → test_virtual_base_not_at_offset_0() and replace pytest.skip() with assert. Add helpful comment for future maintainers.
1 parent 0df90e6 commit 9dbd9f1

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

tests/test_class_sh_mi_thunks.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,26 @@ def test_get_shared_vec_size_unique():
5353
)
5454

5555

56-
def test_virtual_base_at_offset_0():
56+
def test_virtual_base_not_at_offset_0():
57+
# This test ensures that the Diamond fixture actually exercises a non-zero
58+
# virtual-base subobject offset on our supported platforms/ABIs.
59+
#
60+
# If this assert ever fails on some platform/toolchain, please adjust the
61+
# C++ fixture so the virtual base is *not* at offset 0:
62+
# - Keep VBase non-empty.
63+
# - Make Left and Right non-empty and asymmetrically sized and, if
64+
# needed, nudge with a modest alignment.
65+
# - The goal is to achieve a non-zero address delta between `Diamond*`
66+
# and `static_cast<VBase*>(Diamond*)`.
67+
#
68+
# Rationale: certain smart_holder features are exercised only when the
69+
# registered subobject address differs from the most-derived object start,
70+
# so this check guards test efficacy across compilers.
5771
addrs = m.diamond_addrs()
58-
if addrs.as_vbase - addrs.as_self == 0:
59-
# Not an actual skip, just a trick generate a message in the pytest summary
60-
pytest.skip("virtual base at offset 0 on this compiler/layout")
72+
assert addrs.as_vbase - addrs.as_self != 0, (
73+
"Diamond VBase at offset 0 on this platform; to ensure test efficacy, "
74+
"tweak fixtures (VBase/Left/Right) to ensure non-zero subobject offset."
75+
)
6176

6277

6378
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)