From a0c353d11d11e7ed81da3133688bdb0ce63c2978 Mon Sep 17 00:00:00 2001 From: smheidrich Date: Sun, 9 Oct 2022 23:17:48 +0200 Subject: [PATCH] Initial --- README.md | 75 ++++++++++++++++++++++++++++++++++++++++++++++ README.template.md | 39 ++++++++++++++++++++++++ render.py | 13 ++++++++ 3 files changed, 127 insertions(+) create mode 100644 README.md create mode 100644 README.template.md create mode 100644 render.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..22d9b3d --- /dev/null +++ b/README.md @@ -0,0 +1,75 @@ +# Comparison of pytest plugins for accessing data files + +It is said there are more pytest plugins that aim to provide convenient access +to packaged data files than grains of sand on Earth. Here I compare them all. + +## Comparison + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Name / URLSupports copying to temp dirSupports accessing without copyingPaths provided asFixture namesFolder names
+pytest-datadir + +True + +False + +pathlib.Path + +`datadir`, `shared_datadir` + +`data`, `test_TEST_NAME` +
+pytest-datadir-ng + +True + +True + +py.path + +`datadir`, `datadir_copy` + +`data`, `data/test_TEST_NAME`, `test_TEST_NAME` +
+pytest-datafixtures + +False + +True + +pathlib.Path + +`datafix`, `datafix_dir`, `datafix_read`, `datafix_readbin` + +`datafixtures`, `**/datafixtures` +
\ No newline at end of file diff --git a/README.template.md b/README.template.md new file mode 100644 index 0000000..ebe59e1 --- /dev/null +++ b/README.template.md @@ -0,0 +1,39 @@ +# Comparison of pytest plugins for accessing data files + +It is said there are more pytest plugins that aim to provide convenient access +to packaged data files than grains of sand on Earth. Here I compare them all. + +## Comparison + + + + + + + + + +{%- for plugin in plugins %} + + + + + + + +{%- endfor %} + +
+Name / URLSupports copying to temp dirSupports accessing without copyingPaths provided asFixture namesFolder names
+{{ plugin.name }} + +{{ plugin.supports_copying_to_temp }} + +{{ plugin.supports_access_without_copying }} + +{{ plugin.provided_as }} + +{{ plugin.fixture_names|map('tojson')|join(', ')|replace('"', '`') }} + +{{ plugin.folder_names|map('tojson')|join(', ')|replace('"', '`') }} +
diff --git a/render.py b/render.py new file mode 100644 index 0000000..4bba214 --- /dev/null +++ b/render.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +# $ pip list | grep -iE '(jinja|pyyaml)' +# Jinja2 3.0.1 +# PyYAML 5.3.1 +from jinja2 import Template +from pathlib import Path +import yaml + +t = Template(Path("README.template.md").read_text()) +with Path("data.yml").open() as f: + d = yaml.load(f, Loader=yaml.SafeLoader) +s = t.render(d) +Path("README.md").write_text(s)