How to use the ward.Scope function in ward

To help you get started, we’ve selected a few ward examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github darrenburns / ward / tests / test_fixtures.py View on Github external
    @fixture(scope=Scope.Global)
    def g():
        yield "g"
        events.append("teardown g")
github darrenburns / ward / tests / test_fixtures.py View on Github external
def _(cache: FixtureCache = cache, t: Test = my_test):
    cache.teardown_fixtures_for_scope(Scope.Test, t.id)

    fixtures_at_scope = cache.get_fixtures_at_scope(Scope.Test, t.id)

    expect(fixtures_at_scope).equals({})
github darrenburns / ward / tests / test_fixtures.py View on Github external
def _(f=exception_raising_fixture):
    cache = FixtureCache()
    cache.cache_fixture(f, "test_id")

    expect(cache.get(f.key, Scope.Test, "test_id")).equals(f)
github darrenburns / ward / tests / test_fixtures.py View on Github external
    @fixture(scope=Scope.Module)
    def m():
        yield "m"
        events.append("teardown m")
github darrenburns / ward / ward / suite.py View on Github external
generated_test(**resolved_vals)
                    outcome = (
                        TestOutcome.XPASS if marker == "XFAIL" else TestOutcome.PASS
                    )
                    yield generated_test.get_result(outcome)
                except FixtureError as e:
                    yield generated_test.get_result(TestOutcome.FAIL, e)
                    continue
                except Exception as e:
                    outcome = (
                        TestOutcome.XFAIL if marker == "XFAIL" else TestOutcome.FAIL
                    )
                    yield generated_test.get_result(outcome, e)
                finally:
                    self.cache.teardown_fixtures_for_scope(
                        Scope.Test, scope_key=generated_test.id
                    )
                    if num_tests_per_module[generated_test.path] == 0:
                        self.cache.teardown_fixtures_for_scope(
                            Scope.Module, scope_key=generated_test.path
                        )

        self.cache.teardown_global_fixtures()
github darrenburns / ward / ward / suite.py View on Github external
yield generated_test.get_result(outcome)
                except FixtureError as e:
                    yield generated_test.get_result(TestOutcome.FAIL, e)
                    continue
                except Exception as e:
                    outcome = (
                        TestOutcome.XFAIL if marker == "XFAIL" else TestOutcome.FAIL
                    )
                    yield generated_test.get_result(outcome, e)
                finally:
                    self.cache.teardown_fixtures_for_scope(
                        Scope.Test, scope_key=generated_test.id
                    )
                    if num_tests_per_module[generated_test.path] == 0:
                        self.cache.teardown_fixtures_for_scope(
                            Scope.Module, scope_key=generated_test.path
                        )

        self.cache.teardown_global_fixtures()