def test_setting_the_same_value_marks_field_as_dirty():
 class FieldTester(XBlock, ):
  'Test block for set - get test.'
  non_mutable = String(scope=Scope.settings)
  list_field = List(scope=Scope.settings)
  dict_field = Dict(scope=Scope.settings)
 runtime = TestRuntime(services={'field-data': DictFieldData({})})
 field_tester = FieldTester(runtime, scope_ids=Mock(spec=ScopeIds))
 assert_equals(len(field_tester._dirty_fields), 0)
 assert_false(field_tester.fields['list_field'].is_set_on(field_tester))
 assert_false(field_tester.fields['dict_field'].is_set_on(field_tester))
 assert_false(field_tester.fields['non_mutable'].is_set_on(field_tester))
 field_tester.non_mutable = field_tester.non_mutable
 field_tester.list_field = field_tester.list_field
 field_tester.dict_field = field_tester.dict_field
 assert_not_in(field_tester.fields['non_mutable'], field_tester._dirty_fields)
 assert_in(field_tester.fields['list_field'], field_tester._dirty_fields)
 assert_in(field_tester.fields['dict_field'], field_tester._dirty_fields)
 assert_false(field_tester.fields['non_mutable'].is_set_on(field_tester))
 assert_false(field_tester.fields['list_field'].is_set_on(field_tester))
 assert_false(field_tester.fields['dict_field'].is_set_on(field_tester))

def test_setting_the_same_value_marks_field_as_dirty ( ) : class FieldTester ( XBlock , ) : non_mutable = String ( scope = Scope . settings ) list_field = List ( scope = Scope . settings ) dict_field = Dict ( scope = Scope . settings ) runtime = TestRuntime ( services = { 'field-data' : DictFieldData ( { } ) } ) field_tester = FieldTester ( runtime , scope_ids = Mock ( spec = ScopeIds ) ) assert_equals ( len ( field_tester . _dirty_fields ) , 0 ) assert_false ( field_tester . fields [ 'list_field' ] . is_set_on ( field_tester ) ) assert_false ( field_tester . fields [ 'dict_field' ] . is_set_on ( field_tester ) ) assert_false ( field_tester . fields [ 'non_mutable' ] . is_set_on ( field_tester ) ) field_tester . non_mutable = field_tester . non_mutable field_tester . list_field = field_tester . list_field field_tester . dict_field = field_tester . dict_field assert_not_in ( field_tester . fields [ 'non_mutable' ] , field_tester . _dirty_fields ) assert_in ( field_tester . fields [ 'list_field' ] , field_tester . _dirty_fields ) assert_in ( field_tester . fields [ 'dict_field' ] , field_tester . _dirty_fields ) assert_false ( field_tester . fields [ 'non_mutable' ] . is_set_on ( field_tester ) ) assert_false ( field_tester . fields [ 'list_field' ] . is_set_on ( field_tester ) ) assert_false ( field_tester . fields [ 'dict_field' ] . is_set_on ( field_tester ) )
check that setting field to the same value marks mutable fields as dirty .