@@ -0,0 +1,1214 @@
+from traits.testing.unittest_tools import unittest%0A%0Afrom traits.api import Float, HasTraits, Int, List%0A%0A%0Aclass Foo(HasTraits):%0A    x = Float%0A%0A    x_changes = List%0A    y_changes = List%0A%0A    def _x_changed(self, new):%0A        self.x_changes.append(new)%0A%0A    def _y_changed(self, new):%0A        self.y_changes.append(new)%0A%0A%0Aclass TestDynamicTraitDefinition(unittest.TestCase):%0A    %22%22%22 Test demonstrating special change events using the 'event' metadata.%0A    %22%22%22%0A%0A    def test_add_trait(self):%0A        foo = Foo(x=3)%0A        foo.add_trait('y', Int)%0A%0A        self.assertTrue(hasattr(foo, 'y'))%0A        self.assertEqual(type(foo.y), int)%0A%0A        foo.y = 4%0A        self.assertEqual(foo.y_changes, %5B4%5D)%0A%0A    def test_remove_trait(self):%0A        foo = Foo(x=3)%0A%0A        # We can't remove a %22statically%22 added trait (i.e., a trait defined%0A        # in the Foo class).%0A        result = foo.remove_trait('x')%0A        self.assertFalse(result)%0A%0A        # We can remove dynamically added traits.%0A        foo.add_trait('y', Int)%0A        foo.y = 70%0A%0A        result = foo.remove_trait('y')%0A        self.assertTrue(result)%0A%0A        self.assertFalse(hasattr(foo, 'y'))%0A        foo.y = 10%0A        self.assertEqual(foo.y_changes, %5B70%5D)%0A

Add tests for `add_trait` and `remove_trait`.