Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _(anonymous_test=anonymous_test):
expect(anonymous_test.has_deps).equals(False)
Test(fn=test3, module_name="module2"),
]
)
list(suite.generate_test_runs())
expect(events).equals(
[
"resolve", # Resolve at start of run only
"test1",
"test2",
"test3",
"teardown", # Teardown only at end of run
]
)
expect(len(suite.cache)).equals(0) # Teardown includes cache cleanup
def _(suite=suite):
results = list(suite.generate_test_runs())
expected = [
TestResult(test=test, outcome=TestOutcome.PASS, error=None, message="")
for test in suite.tests
]
expect(results).equals(expected)
def _(mock):
mock(2)
mock(1)
e = expect(mock)
with raises(ExpectationFailed):
e.called_with(2)
expect(e.history[0].success).equals(False)
def _():
expect(1).equals(1)
def _(dependent_test=dependent_test):
deps = dependent_test.deps()
expect(deps).contains("a")
def _(isclose):
this, that = 1.0, 1.2
abs_tol = 0.01
with raises(ExpectationFailed):
expect(this).not_approx(that, abs_tol=abs_tol)
expect(isclose).called_once_with(this, that, abs_tol=abs_tol, rel_tol=1e-9)
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)
def _(cache: FixtureCache = cache, events: List = recorded_events):
cache.teardown_fixtures_for_scope(Scope.Module, testable_test.path)
expect(events).equals(["teardown m"])
def _(mock):
args = (1, 2, 3)
kwargs = {"hello": "world"}
mock(*args, **kwargs)
mock(*args, **kwargs)
e = expect(mock)
with raises(ExpectationFailed):
e.called_once_with(*args, **kwargs)
hist = [
Expected(
mock,
op="called_once_with",
that=None,
op_args=args,
op_kwargs=kwargs,
success=False,
)
]
expect(e.history).equals(hist)