aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-09-28 15:46:13 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:18:17 -0300
commitf0aa20eda397c9e734ced759634031f77662c0de (patch)
tree2764a3fa7800653cbeb9b0e7ca140b2844006ebe /tests
parent52fdebcb0b3822180a374ee821f3503d746656c1 (diff)
Updated enum_test for support py3k.
Diffstat (limited to 'tests')
-rw-r--r--tests/samplebinding/enum_test.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/samplebinding/enum_test.py b/tests/samplebinding/enum_test.py
index 0cbc0697a..f81f8b0a8 100644
--- a/tests/samplebinding/enum_test.py
+++ b/tests/samplebinding/enum_test.py
@@ -32,6 +32,14 @@ import unittest
import sample
from sample import SampleNamespace, ObjectType, Event
+from py3kcompat import IS_PY3K, b
+
+def createTempFile():
+ if IS_PY3K:
+ import tempfile
+ return tempfile.SpooledTemporaryFile(mode='rw')
+ else:
+ return os.tmpfile()
class EnumTest(unittest.TestCase):
'''Test case for Python representation of C++ enums.'''
@@ -96,10 +104,8 @@ class EnumTest(unittest.TestCase):
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 = createTempFile()
+ print(Event.ANY_EVENT, file=tmpfile)
tmpfile.seek(0)
text = tmpfile.read().strip()
tmpfile.close()