Convert two tests to work with both Python 2 and 3
Now these two tests work without having to use 2to3
This commit is contained in:
parent
d820045336
commit
982b08dced
2 changed files with 21 additions and 8 deletions
|
|
@ -1,7 +1,11 @@
|
|||
import python_destructor_exception
|
||||
from StringIO import StringIO
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] < (3, 0):
|
||||
import StringIO as io
|
||||
else:
|
||||
import io
|
||||
|
||||
def error_function():
|
||||
python_destructor_exception.ClassWithThrowingDestructor().GetBlah()
|
||||
|
||||
|
|
@ -9,13 +13,13 @@ def runtest():
|
|||
attributeErrorOccurred = False
|
||||
try:
|
||||
error_function()
|
||||
except AttributeError, e:
|
||||
except AttributeError:
|
||||
attributeErrorOccurred = True
|
||||
return attributeErrorOccurred
|
||||
|
||||
def test1():
|
||||
stderr_saved = sys.stderr
|
||||
buffer = StringIO()
|
||||
buffer = io.StringIO()
|
||||
attributeErrorOccurred = False
|
||||
try:
|
||||
# Suppress stderr while making this call to suppress the output shown by PyErr_WriteUnraisable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue