/usr/lib/python2.7/dist-packages/traits/tests/test_enum.py is in python-traits 4.6.0-1.
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 | from traits.testing.unittest_tools import unittest
from traits.api import Enum, HasTraits, List, Property, TraitError
class ExampleModel(HasTraits):
valid_models = Property(List)
root = Enum(values='valid_models')
def _get_valid_models(self):
return ['model1', 'model2', 'model3']
class EnumTestCase(unittest.TestCase):
def test_valid_enum(self):
example_model = ExampleModel(root='model1')
example_model.root = 'model2'
def test_invalid_enum(self):
example_model = ExampleModel(root='model1')
def assign_invalid():
example_model.root = 'not_valid_model'
self.assertRaises(TraitError, assign_invalid)
|