diff --git a/_pytest/monkeypatch.py b/_pytest/monkeypatch.py index 43b8c2fe1..4431d25b3 100644 --- a/_pytest/monkeypatch.py +++ b/_pytest/monkeypatch.py @@ -45,7 +45,8 @@ def resolve(name): try: __import__(used) except ImportError as ex: - expected = ex.message.split()[-1] + # str is used for py2 vs py3 + expected = str(ex).split()[-1] if expected == used: raise else: