MCPcopy
hub / github.com/reflex-dev/reflex / _test

Function _test

tests/units/test_app.py:3489–3520  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3487 """set_contexts sets absent contexts, preserves existing ones, and resets on exit."""
3488
3489 def _test():
3490 with app_with_processor.set_contexts():
3491 # Pre-existing contexts are preserved; absent ones are filled in.
3492 if pre_set_registration_context is not None:
3493 assert RegistrationContext.get() is pre_set_registration_context
3494 else:
3495 assert (
3496 RegistrationContext.get()
3497 is app_with_processor._registration_context
3498 )
3499
3500 if pre_set_event_context is not None:
3501 assert EventContext.get() is pre_set_event_context
3502 else:
3503 assert app_with_processor._event_processor is not None
3504 assert (
3505 EventContext.get()
3506 is app_with_processor._event_processor._root_context
3507 )
3508
3509 # After exit: pushed contexts are reset, pre-existing ones remain.
3510 if pre_set_registration_context is not None:
3511 assert RegistrationContext.get() is pre_set_registration_context
3512 else:
3513 with pytest.raises(LookupError):
3514 RegistrationContext.get()
3515
3516 if pre_set_event_context is not None:
3517 assert EventContext.get() is pre_set_event_context
3518 else:
3519 with pytest.raises(LookupError):
3520 EventContext.get()
3521
3522 isolated_context.run(_test)
3523

Callers

nothing calls this directly

Calls 3

set_contextsMethod · 0.95
AppClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected