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

Function test_mutable_set

tests/units/test_state.py:2921–2960  ·  view source on GitHub ↗

Test that mutable sets are tracked correctly. Args: mutable_state: A test state.

(mutable_state: MutableTestState)

Source from the content-addressed store, hash-verified

2919
2920
2921def test_mutable_set(mutable_state: MutableTestState):
2922 """Test that mutable sets are tracked correctly.
2923
2924 Args:
2925 mutable_state: A test state.
2926 """
2927 assert not mutable_state.dirty_vars
2928
2929 def assert_set_dirty():
2930 assert mutable_state.dirty_vars == {"test_set"}
2931 mutable_state._clean()
2932 assert not mutable_state.dirty_vars
2933
2934 # Test all set operations
2935 mutable_state.test_set.add(42)
2936 assert_set_dirty()
2937 mutable_state.test_set.update([1, 2, 3])
2938 assert_set_dirty()
2939 mutable_state.test_set.remove(42)
2940 assert_set_dirty()
2941 mutable_state.test_set.discard(3)
2942 assert_set_dirty()
2943 mutable_state.test_set.pop()
2944 assert_set_dirty()
2945 mutable_state.test_set.intersection_update([1, 2, 3])
2946 assert_set_dirty()
2947 mutable_state.test_set.difference_update([99])
2948 assert_set_dirty()
2949 mutable_state.test_set.symmetric_difference_update([102, 99])
2950 assert_set_dirty()
2951 mutable_state.test_set |= {1, 2, 3}
2952 assert_set_dirty()
2953 mutable_state.test_set &= {2, 3, 4}
2954 assert_set_dirty()
2955 mutable_state.test_set -= {2}
2956 assert_set_dirty()
2957 mutable_state.test_set ^= {42}
2958 assert_set_dirty()
2959 mutable_state.test_set.clear()
2960 assert_set_dirty()
2961
2962
2963def test_mutable_custom(mutable_state: MutableTestState):

Callers

nothing calls this directly

Calls 4

assert_set_dirtyFunction · 0.85
removeMethod · 0.80
clearMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected