Esempio n. 1
0
    def assertAtomDoesNotChange(
            self, obj, atom, callableObj=None, *args, **kwargs):
        """Assert an object atom does not change.

        Assert that the class atom does not change during execution of the
        provided function.

        """
        msg = 'A change event was fired for: {0}'.format(atom)
        context = _AssertAtomChangesContext(obj, atom, None, self)
        if callableObj is None:
            return reverse_assertion(context, msg)
        with reverse_assertion(context, msg):
            callableObj(*args, **kwargs)
    def test_event_loop_until_trait_change(self):
        with self.assertRaises(AssertionError):
            with self.event_loop_until_traits_change(self.my_class,
                                                     'number',
                                                     timeout=1.0):
                pass

        with reverse_assertion(self.assertRaises(AssertionError),
                               'Assertion should not be raised'):
            with self.event_loop_until_traits_change(self.my_class, 'number'):
                deferred_call(self._set_trait, 5.0)
    def test_event_loop_until_trait_change(self):
        with self.assertRaises(AssertionError):
            with self.event_loop_until_traits_change(
                    self.my_class, 'number', timeout=1.0):
                pass

        with reverse_assertion(
                self.assertRaises(AssertionError),
                'Assertion should not be raised'):
            with self.event_loop_until_traits_change(
                    self.my_class, 'number'):
                deferred_call(self._set_trait, 5.0)