本文整理汇总了Python中_pytest.skipping.MarkEvaluator.istrue方法的典型用法代码示例。如果您正苦于以下问题:Python MarkEvaluator.istrue方法的具体用法?Python MarkEvaluator.istrue怎么用?Python MarkEvaluator.istrue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_pytest.skipping.MarkEvaluator
的用法示例。
在下文中一共展示了MarkEvaluator.istrue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_marked_one_arg_unicode
# 需要导入模块: from _pytest.skipping import MarkEvaluator [as 别名]
# 或者: from _pytest.skipping.MarkEvaluator import istrue [as 别名]
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')"
示例2: test_marked_one_arg_twice2
# 需要导入模块: from _pytest.skipping import MarkEvaluator [as 别名]
# 或者: from _pytest.skipping.MarkEvaluator import istrue [as 别名]
def test_marked_one_arg_twice2(self, testdir):
item = testdir.getitem("""
import pytest
@pytest.mark.skipif("hasattr(os, 'murks')")
@pytest.mark.skipif("not hasattr(os, 'murks')")
def test_func():
pass
""")
ev = MarkEvaluator(item, 'skipif')
assert ev
assert ev.istrue()
expl = ev.getexplanation()
assert expl == "condition: not hasattr(os, 'murks')"
示例3: test_marked_one_arg_with_reason
# 需要导入模块: from _pytest.skipping import MarkEvaluator [as 别名]
# 或者: from _pytest.skipping.MarkEvaluator import istrue [as 别名]
def test_marked_one_arg_with_reason(self, testdir):
item = testdir.getitem("""
import pytest
@pytest.mark.xyz("hasattr(os, 'sep')", attr=2, reason="hello world")
def test_func():
pass
""")
ev = MarkEvaluator(item, 'xyz')
assert ev
assert ev.istrue()
expl = ev.getexplanation()
assert expl == "hello world"
assert ev.get("attr") == 2
示例4: test_marked_no_args
# 需要导入模块: from _pytest.skipping import MarkEvaluator [as 别名]
# 或者: from _pytest.skipping.MarkEvaluator import istrue [as 别名]
def test_marked_no_args(self, testdir):
item = testdir.getitem("""
import pytest
@pytest.mark.xyz
def test_func():
pass
""")
ev = MarkEvaluator(item, 'xyz')
assert ev
assert ev.istrue()
expl = ev.getexplanation()
assert expl == ""
assert not ev.get("run", False)
示例5: test_skipif_class
# 需要导入模块: from _pytest.skipping import MarkEvaluator [as 别名]
# 或者: from _pytest.skipping.MarkEvaluator import istrue [as 别名]
def test_skipif_class(self, testdir):
item, = testdir.getitems("""
import pytest
class TestClass(object):
pytestmark = pytest.mark.skipif("config._hackxyz")
def test_func(self):
pass
""")
item.config._hackxyz = 3
ev = MarkEvaluator(item, 'skipif')
assert ev.istrue()
expl = ev.getexplanation()
assert expl == "condition: config._hackxyz"
示例6: test_marked_one_arg_twice
# 需要导入模块: from _pytest.skipping import MarkEvaluator [as 别名]
# 或者: from _pytest.skipping.MarkEvaluator import istrue [as 别名]
def test_marked_one_arg_twice(self, testdir):
lines = [
'''@pytest.mark.skipif("not hasattr(os, 'murks')")''',
'''@pytest.mark.skipif("hasattr(os, 'murks')")'''
]
for i in range(0, 2):
item = testdir.getitem("""
import pytest
%s
%s
def test_func():
pass
""" % (lines[i], lines[(i + 1) % 2]))
ev = MarkEvaluator(item, 'skipif')
assert ev
assert ev.istrue()
expl = ev.getexplanation()
assert expl == "condition: not hasattr(os, 'murks')"
示例7: test_no_marker
# 需要导入模块: from _pytest.skipping import MarkEvaluator [as 别名]
# 或者: from _pytest.skipping.MarkEvaluator import istrue [as 别名]
def test_no_marker(self, testdir):
item = testdir.getitem("def test_func(): pass")
evalskipif = MarkEvaluator(item, 'skipif')
assert not evalskipif
assert not evalskipif.istrue()