Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@test("Test.is_parameterised should return True for parameterised test")
def _():
def parameterised_test(a=each(1, 2, 3), b="a value"):
pass
t = Test(fn=parameterised_test, module_name=mod)
expect(t.is_parameterised).equals(True)
@test("Test.has_deps should return False when test doesn't use fixtures")
def _(anonymous_test=anonymous_test):
expect(anonymous_test.has_deps).equals(False)
@test("Suite.generate_test_runs fixture teardown code is ran in the expected order")
def _(module=module):
events = []
@fixture
def fix_a():
events.append(1)
yield "a"
events.append(3)
@fixture
def fix_b():
events.append(2)
return "b"
def my_test(fix_a=fix_a, fix_b=fix_b):
expect(fix_a).equals("a")
@test(
"Suite.generate_test_runs dependent fixtures of differing scopes behave correctly"
)
def _():
pass
@test("Test.has_deps should return True when test uses fixtures")
def _(dependent_test=dependent_test):
expect(dependent_test.has_deps).equals(True)
@test(
"Suite.generate_test_runs yields a SKIP TestResult when test has @skip decorator "
)
def _(skipped=skipped_test, example=example_test):
suite = Suite(tests=[example, skipped])
test_runs = list(suite.generate_test_runs())
expected_runs = [
TestResult(example, TestOutcome.PASS, None, ""),
TestResult(skipped, TestOutcome.SKIP, None, ""),
]
expect(test_runs).equals(expected_runs)
@test("Test.deps should return correct params when test uses fixtures")
def _(dependent_test=dependent_test):
deps = dependent_test.deps()
expect(deps).contains("a")
@test("Suite.generate_test_runs resolves mixed scope fixtures correctly")
def _():
events = []
@fixture(scope=Scope.Global)
def a():
events.append("resolve a")
yield "a"
events.append("teardown a")
@fixture(scope=Scope.Module)
def b():
events.append("resolve b")
yield "b"
events.append("teardown b")
@fixture(scope=Scope.Test)
@test("Suite.generate_test_runs tears down deep fixtures")
def _(module=module):
events = []
@fixture
def fix_a():
events.append(1)
yield "a"
events.append(4)
@fixture
def fix_b():
events.append(2)
return "b"
@fixture
def fix_c(fix_b=fix_b):
@test("Suite.generate_test_runs resolves and tears down global fixtures once only")
def _():
events = []
@fixture(scope=Scope.Global)
def a():
events.append("resolve")
yield "a"
events.append("teardown")
def test1(a=a):
events.append("test1")
def test2(a=a):
events.append("test2")
def test3(a=a):