From f0aa20eda397c9e734ced759634031f77662c0de Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Wed, 28 Sep 2011 15:46:13 -0300 Subject: Updated enum_test for support py3k. --- tests/samplebinding/enum_test.py | 14 ++++++++++---- 1 file 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() -- cgit v1.2.3