hasattr('xyz', '__iter__') # False in Python 2
from pytest import raises
with raises(NameError):
xrange(10)
with raises(NameError):
basestring
bytes
# TypeError: string argument expected, got 'bytes'
import io
io.BytesIO # Use BytesIO instead of StringIO
from pytest import raises
with raises(ImportError):
import cStringIO
with raises(ImportError):
import StringIO
from six import StringIO
from pytest import raises
with raises(AttributeError):
StringIO().reset
StringIO().seek(0)