Add the ability to use platform in pytest.mark.skipif
This commit is contained in:
parent
da3f4045e7
commit
307cd6630f
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import six
|
||||
import sys
|
||||
import platform
|
||||
import traceback
|
||||
|
||||
from . import MarkDecorator, MarkInfo
|
||||
|
@ -67,7 +68,7 @@ class MarkEvaluator(object):
|
|||
pytrace=False)
|
||||
|
||||
def _getglobals(self):
|
||||
d = {'os': os, 'sys': sys, 'config': self.item.config}
|
||||
d = {'os': os, 'sys': sys, 'platform': platform, 'config': self.item.config}
|
||||
if hasattr(self.item, 'obj'):
|
||||
d.update(self.item.obj.__globals__)
|
||||
return d
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Add the usage of ``platform`` in ``pytest.mark.skipif``
|
|
@ -612,6 +612,16 @@ class TestSkipif(object):
|
|||
])
|
||||
assert result.ret == 0
|
||||
|
||||
def test_skipif_using_platform(self, testdir):
|
||||
item = testdir.getitem("""
|
||||
import pytest
|
||||
@pytest.mark.skipif("platform.platform() == platform.platform()")
|
||||
def test_func():
|
||||
pass
|
||||
""")
|
||||
pytest.raises(pytest.skip.Exception, lambda:
|
||||
pytest_runtest_setup(item))
|
||||
|
||||
@pytest.mark.parametrize('marker, msg1, msg2', [
|
||||
('skipif', 'SKIP', 'skipped'),
|
||||
('xfail', 'XPASS', 'xpassed'),
|
||||
|
|
Loading…
Reference in New Issue