예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
    def test_cv_unicode_context_value(self):
        cv = ContextValue("trait_name")
        cve = CVExample(cv_unicode=cv)

        self.assertIs(cve.cv_unicode, cv)
예제 #4
0
    def test_cv_str_context_value(self):
        cv = ContextValue("trait_name")
        cve = CVExample(cv_str=cv)

        self.assertIs(cve.cv_str, cv)
예제 #5
0
    def test_context_value(self):
        cv = ContextValue("trait_name")

        self.assertEqual(cv.name, "trait_name")
예제 #6
0
    def test_cv_int_context_value(self):
        cv = ContextValue('trait_name')
        cve = CVExample(cv_int=cv)

        self.assertIs(cve.cv_int, cv)
예제 #7
0
    def test_context_value(self):
        cv = ContextValue('trait_name')

        self.assertEqual(cv.name, 'trait_name')