MCPcopy Index your code
hub / github.com/msgspec/msgspec / test_struct_option_precedence

Function test_struct_option_precedence

tests/unit/test_struct.py:1333–1375  ·  view source on GitHub ↗
(option, default)

Source from the content-addressed store, hash-verified

1331 ],
1332)
1333def test_struct_option_precedence(option, default):
1334 def get(cls):
1335 return getattr(cls.__struct_config__, option)
1336
1337 class Default(Struct):
1338 pass
1339
1340 assert get(Default) is default
1341
1342 class Enabled(Struct, **{option: True}):
1343 pass
1344
1345 assert get(Enabled) is True
1346
1347 class Disabled(Struct, **{option: False}):
1348 pass
1349
1350 assert get(Disabled) is False
1351
1352 class T(Enabled):
1353 pass
1354
1355 assert get(T) is True
1356
1357 class T(Enabled, **{option: False}):
1358 pass
1359
1360 assert get(T) is False
1361
1362 class T(Enabled, Default):
1363 pass
1364
1365 assert get(T) is True
1366
1367 class T(Default, Enabled):
1368 pass
1369
1370 assert get(T) is True
1371
1372 class T(Default, Disabled, Enabled):
1373 pass
1374
1375 assert get(T) is False
1376
1377
1378def test_weakref_option():

Callers

nothing calls this directly

Calls 1

getFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…