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

Function test_base_class_vars

tests/units/test_state.py:348–366  ·  view source on GitHub ↗

Test that the class vars are set correctly. Args: test_state: A state.

(test_state)

Source from the content-addressed store, hash-verified

346
347
348def test_base_class_vars(test_state):
349 """Test that the class vars are set correctly.
350
351 Args:
352 test_state: A state.
353 """
354 fields = test_state.get_fields()
355 cls = type(test_state)
356
357 for field_name in fields:
358 if field_name.startswith("_") or field_name in cls.get_skip_vars():
359 continue
360 prop = getattr(cls, field_name)
361 assert isinstance(prop, Var)
362 assert prop._js_expr.split(".")[-1] == field_name + FIELD_MARKER
363
364 assert cls.num1._var_type is int
365 assert cls.num2._var_type is float
366 assert cls.key._var_type is str
367
368
369def test_computed_class_var(test_state):

Callers

nothing calls this directly

Calls 4

startswithMethod · 0.80
get_skip_varsMethod · 0.80
splitMethod · 0.80
get_fieldsMethod · 0.45

Tested by

no test coverage detected