/usr/lib/python2.7/dist-packages/traits/tests/test_special_event_handlers.py is in python-traits 4.5.0-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | from traits.testing.unittest_tools import unittest
from traits.api import Any, HasStrictTraits, Str
class TestSpecialEvent(unittest.TestCase):
""" Test demonstrating special change events using the 'event' metadata.
"""
def setUp(self):
self.change_events = []
self.foo = Foo(test=self)
def test_events(self):
self.foo.val = 'CHANGE'
values = ['CHANGE']
self.failUnlessEqual(self.change_events, values)
def test_instance_events(self):
foo = self.foo
foo.add_trait('val2', Str(event='the_trait'))
foo.val2 = 'CHANGE2'
values = ['CHANGE2']
self.failUnlessEqual(self.change_events, values)
class Foo(HasStrictTraits):
val = Str(event='the_trait')
test = Any(None)
def _the_trait_changed(self, new):
if self.test is not None:
self.test.change_events.append(new)
|