Skip to content

Commit 133864b

Browse files
committed
more python 2.7 related fixes
1 parent ab6288c commit 133864b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/llsd_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,15 +1990,20 @@ def test_parse_magicmock_raises_error(self):
19901990
an infinite loop when passed a MagicMock (e.g., from an improperly
19911991
mocked requests.Response.content).
19921992
'''
1993-
from unittest.mock import MagicMock
1993+
try:
1994+
from unittest.mock import MagicMock
1995+
except ImportError:
1996+
from mock import MagicMock # Python 2.7
19941997
mock = MagicMock()
19951998
with self.assertRaises(llsd.LLSDParseError) as context:
19961999
llsd.parse(mock)
19972000
self.assertIn('MagicMock', str(context.exception))
19982001

2002+
@unittest.skipIf(PY2, "str is bytes in Python 2")
19992003
def test_parse_string_raises_error(self):
20002004
'''
20012005
Parsing a string (not bytes) should raise LLSDParseError.
2006+
Only applies to Python 3 where str and bytes are distinct.
20022007
'''
20032008
with self.assertRaises(llsd.LLSDParseError) as context:
20042009
llsd.parse('not bytes')

0 commit comments

Comments
 (0)