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:
William S Fulton 2020-08-13 23:34:28 +01:00
commit 982b08dced
2 changed files with 21 additions and 8 deletions

View file

@ -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