diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-23 11:36:07 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2010-02-23 11:42:11 -0300 |
commit | 26d74212fcdb0167c71a24872434b3787f2d322d (patch) | |
tree | 7b122e93b0b59b82ebe036a8a69bd822f3083c86 /tests | |
parent | 14a56fd8500a8746bcc78c2b1cb0683e7de8010a (diff) |
The C++-like enum values are now registered inside the related enums.
Originally the values of an enum were registered in the scope that
enclosed the enum declaration, just like C++ does, now in addition
to this the values are registered inside the enum type.
To exemplify, the following C++ enum:
Scope {
enum Foo {
Value
};
};
can be accessed in Python as this:
Scope.Value
as well as this:
Scope.Foo.Value
The enum unit tests were expanded to check for this new behaviour.
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/samplebinding/enum_test.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/samplebinding/enum_test.py b/tests/samplebinding/enum_test.py index bd173d85c..53b4a9b3a 100755 --- a/tests/samplebinding/enum_test.py +++ b/tests/samplebinding/enum_test.py @@ -33,6 +33,13 @@ from sample import SampleNamespace class EnumTest(unittest.TestCase): '''Test case for Python representation of C++ enums.''' + def testEnumValuesInsideEnum(self): + '''Enum values should be accessible inside the enum as well as outside.''' + for value_name in SampleNamespace.Option.values: + enum_item1 = getattr(SampleNamespace.Option, value_name) + enum_item2 = getattr(SampleNamespace, value_name) + self.assertEqual(enum_item1, enum_item2) + def testPassingIntegerOnEnumArgument(self): '''Tries to use an integer in place of an enum argument.''' self.assertRaises(TypeError, SampleNamespace.getNumber, 1) |