diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-01-21 10:21:16 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:12:54 -0300 |
commit | b18a0f63b93a6ad9f047d10408d98d0fb548919d (patch) | |
tree | 148a8930207961cc11fb9f451dcb1a74e64b71c0 /tests | |
parent | ea66e79f338202f473bc1e95e21c126bbb63756a (diff) |
Shiboken enums now have a tp_print representation.
This fixes the bug #611[1], and an unit test was also added.
[1] http://bugs.openbossa.org/show_bug.cgi?id=611
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Luciano Wolf <luciano.wolf@openbossa.org>
Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/samplebinding/enum_test.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/samplebinding/enum_test.py b/tests/samplebinding/enum_test.py index 71ebef60f..698287f9d 100644 --- a/tests/samplebinding/enum_test.py +++ b/tests/samplebinding/enum_test.py @@ -26,6 +26,8 @@ '''Test cases for Python representation of C++ enums.''' +import os +import sys import unittest import sample @@ -83,6 +85,18 @@ class EnumTest(unittest.TestCase): self.assertEqual(SampleNamespace.AnonymousClassEnum_Value0, 0) self.assertEqual(SampleNamespace.AnonymousClassEnum_Value1, 1) + def testEnumTpPrintImplementation(self): + '''Without SbkEnum.tp_print 'print' returns the enum represented as an int.''' + tmpfile = os.tmpfile() + sys.stdout = tmpfile + print Event.ANY_EVENT + sys.stdout = sys.__stdout__ + tmpfile.seek(0) + text = tmpfile.read().strip() + tmpfile.close() + self.assertEqual(text, str(Event.ANY_EVENT)) + self.assertEqual(text, repr(Event.ANY_EVENT)) + class EnumOverloadTest(unittest.TestCase): '''Test case for overloads involving enums''' |