diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/tools/pytest/doc/en/example/nonpython | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/tools/pytest/doc/en/example/nonpython')
3 files changed, 47 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/pytest/doc/en/example/nonpython/__init__.py b/testing/web-platform/tests/tools/pytest/doc/en/example/nonpython/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/testing/web-platform/tests/tools/pytest/doc/en/example/nonpython/__init__.py diff --git a/testing/web-platform/tests/tools/pytest/doc/en/example/nonpython/conftest.py b/testing/web-platform/tests/tools/pytest/doc/en/example/nonpython/conftest.py new file mode 100644 index 000000000..2406e8f10 --- /dev/null +++ b/testing/web-platform/tests/tools/pytest/doc/en/example/nonpython/conftest.py @@ -0,0 +1,40 @@ +# content of conftest.py + +import pytest + +def pytest_collect_file(parent, path): + if path.ext == ".yml" and path.basename.startswith("test"): + return YamlFile(path, parent) + +class YamlFile(pytest.File): + def collect(self): + import yaml # we need a yaml parser, e.g. PyYAML + raw = yaml.safe_load(self.fspath.open()) + for name, spec in raw.items(): + yield YamlItem(name, self, spec) + +class YamlItem(pytest.Item): + def __init__(self, name, parent, spec): + super(YamlItem, self).__init__(name, parent) + self.spec = spec + + def runtest(self): + for name, value in self.spec.items(): + # some custom test execution (dumb example follows) + if name != value: + raise YamlException(self, name, value) + + def repr_failure(self, excinfo): + """ called when self.runtest() raises an exception. """ + if isinstance(excinfo.value, YamlException): + return "\n".join([ + "usecase execution failed", + " spec failed: %r: %r" % excinfo.value.args[1:3], + " no further details known at this point." + ]) + + def reportinfo(self): + return self.fspath, 0, "usecase: %s" % self.name + +class YamlException(Exception): + """ custom exception for error reporting. """ diff --git a/testing/web-platform/tests/tools/pytest/doc/en/example/nonpython/test_simple.yml b/testing/web-platform/tests/tools/pytest/doc/en/example/nonpython/test_simple.yml new file mode 100644 index 000000000..f0d8d11fc --- /dev/null +++ b/testing/web-platform/tests/tools/pytest/doc/en/example/nonpython/test_simple.yml @@ -0,0 +1,7 @@ +# test_simple.yml +ok: + sub1: sub1 + +hello: + world: world + some: other |