diff --git a/_pytest/skipping.py b/_pytest/skipping.py index a7626eedf..fece24ff3 100644 --- a/_pytest/skipping.py +++ b/_pytest/skipping.py @@ -3,6 +3,12 @@ import py, pytest import sys +# Provide basestring in python3 +try: + basestring = basestring +except NameError: + basestring = str + def pytest_addoption(parser): group = parser.getgroup("general") group.addoption('--runxfail', @@ -86,7 +92,7 @@ class MarkEvaluator: self.result = False for expr in self.holder.args: self.expr = expr - if isinstance(expr, str): + if isinstance(expr, basestring): result = cached_eval(self.item.config, expr, d) else: pytest.fail("expression is not a string") diff --git a/testing/test_skipping.py b/testing/test_skipping.py index bc60f8122..03e9b6780 100644 --- a/testing/test_skipping.py +++ b/testing/test_skipping.py @@ -39,6 +39,20 @@ class TestEvaluator: expl = ev.getexplanation() assert expl == "condition: hasattr(os, 'sep')" + @pytest.mark.skipif('sys.version_info[0] >= 3') + def test_marked_one_arg_unicode(self, testdir): + item = testdir.getitem(""" + import pytest + @pytest.mark.xyz(u"hasattr(os, 'sep')") + def test_func(): + pass + """) + ev = MarkEvaluator(item, 'xyz') + assert ev + assert ev.istrue() + expl = ev.getexplanation() + assert expl == "condition: hasattr(os, 'sep')" + def test_marked_one_arg_with_reason(self, testdir): item = testdir.getitem(""" import pytest