def test_sync_value_from_cv(self): factory = StubEditorFactory( auxiliary_cv_int=ContextValue("object.user_auxiliary")) editor = create_editor(factory=factory) user_object = editor.object with self.assertTraitChanges(editor, "auxiliary_cv_int", count=1): editor.prepare(None) self.assertEqual(editor.auxiliary_cv_int, 10) with self.assertTraitChanges(editor, "auxiliary_cv_int", count=1): user_object.user_auxiliary = 11 self.assertEqual(editor.auxiliary_cv_int, 11) editor.dispose() with self.assertTraitDoesNotChange(editor, "auxiliary_cv_int"): user_object.user_auxiliary = 12
def test_sync_value_to_cv(self): factory = StubEditorFactory( auxiliary_cv_float=ContextValue("object.user_auxiliary")) editor = create_editor(factory=factory) user_object = editor.object editor.auxiliary_cv_float = 20.0 with self.assertTraitChanges(user_object, "user_auxiliary", count=1): editor.prepare(None) self.assertEqual(user_object.user_auxiliary, 20) with self.assertTraitChanges(user_object, "user_auxiliary", count=1): editor.auxiliary_cv_float = 11.0 self.assertEqual(user_object.user_auxiliary, 11) editor.dispose() with self.assertTraitDoesNotChange(user_object, "user_auxiliary"): editor.auxiliary_cv_float = 12.0
def test_cv_unicode_context_value(self): cv = ContextValue("trait_name") cve = CVExample(cv_unicode=cv) self.assertIs(cve.cv_unicode, cv)
def test_cv_str_context_value(self): cv = ContextValue("trait_name") cve = CVExample(cv_str=cv) self.assertIs(cve.cv_str, cv)
def test_context_value(self): cv = ContextValue("trait_name") self.assertEqual(cv.name, "trait_name")
def test_cv_int_context_value(self): cv = ContextValue('trait_name') cve = CVExample(cv_int=cv) self.assertIs(cve.cv_int, cv)
def test_context_value(self): cv = ContextValue('trait_name') self.assertEqual(cv.name, 'trait_name')