From 3492dd291a71ffd3f86f01ca45b50a68759cdde5 Mon Sep 17 00:00:00 2001 From: MinchinWeb Date: Sun, 16 May 2021 21:12:32 -0600 Subject: [PATCH] [Tests] don't name test plugin 'testing" If so named, pip won't install it. --- docs/plugins.md | 3 +- features/environment.py | 2 +- features/plugins.feature | 38 +++++++++---------- .../contrib/exporter/{testing.py => flag.py} | 2 + .../jrnl/contrib/importer/.gitkeep | 0 .../{sample_json.py => simple_json.py} | 0 6 files changed, 24 insertions(+), 21 deletions(-) rename tests/external_plugins_src/jrnl/contrib/exporter/{testing.py => flag.py} (91%) delete mode 100644 tests/external_plugins_src/jrnl/contrib/importer/.gitkeep rename tests/external_plugins_src/jrnl/contrib/importer/{sample_json.py => simple_json.py} (100%) diff --git a/docs/plugins.md b/docs/plugins.md index 72ae4fa6..7d81ec8b 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -168,6 +168,7 @@ situations other than a traditional export. They are: - editable installs (`pip install -e ...`) don't seem to play nice with the namespace layout. If your plugin isn't appearing, try a non-editable install of both *jrnl* and your plugin. -- for examples, you can look to the *jrnl*'s internal importers and exporters. +- Don't name your plugin file "testing.py" or it won't be installed (at least + automatically) by pip. As well, there are some basic external examples included in *jrnl*'s git repo at `tests/external_plugins_src` (including the example code above). diff --git a/features/environment.py b/features/environment.py index 803a6d20..87053163 100644 --- a/features/environment.py +++ b/features/environment.py @@ -5,7 +5,7 @@ import shutil from jrnl.os_compat import on_windows try: - from jrnl.contrib.exporter import testing as testing_exporter + from jrnl.contrib.exporter import flag as testing_exporter except ImportError: testing_exporter = None diff --git a/features/plugins.feature b/features/plugins.feature index 530ac2d7..0c95626f 100644 --- a/features/plugins.feature +++ b/features/plugins.feature @@ -33,25 +33,25 @@ Feature: Functionality of Importer and Exporter Plugins Then the output should contain pyproject.toml version And The output should contain " : from jrnl..." Examples: - | plugin_name | version | source | type | filename | - | jrnl | | plugins | importer | jrnl | - | json | v1.0.0 | contrib | importer | json | - | boxed | | plugins | exporter | fancy | - | dates | | plugins | exporter | dates | - | default | | plugins | exporter | pretty | - | fancy | | plugins | exporter | fancy | - | json | v1.0.0 | contrib | exporter | json | - | markdown | | plugins | exporter | markdown | - | md | | plugins | exporter | markdown | - | pretty | | plugins | exporter | pretty | - | rot13 | v1.0.0 | contrib | exporter | rot13 | - | short | | plugins | exporter | short | - | tags | | plugins | exporter | tag | - | testing | v0.0.1 | contrib | exporter | testing | - | text | | plugins | exporter | text | - | txt | v1.0.0 | contrib | exporter | rot13 | - | xml | | plugins | exporter | xml | - | yaml | | plugins | exporter | yaml | + | plugin_name | version | source | type | filename | + | jrnl | | plugins | importer | jrnl | + | json | v1.0.0 | contrib | importer | simple_json | + | boxed | | plugins | exporter | fancy | + | dates | | plugins | exporter | dates | + | default | | plugins | exporter | pretty | + | fancy | | plugins | exporter | fancy | + | json | v1.0.0 | contrib | exporter | custom_json | + | markdown | | plugins | exporter | markdown | + | md | | plugins | exporter | markdown | + | pretty | | plugins | exporter | pretty | + | rot13 | v1.0.0 | contrib | exporter | rot13 | + | short | | plugins | exporter | short | + | tags | | plugins | exporter | tag | + | testing | v0.0.1 | contrib | exporter | flag | + | text | | plugins | exporter | text | + | txt | v1.0.0 | contrib | exporter | rot13 | + | xml | | plugins | exporter | xml | + | yaml | | plugins | exporter | yaml | @skip_only_with_external_plugins Scenario Outline: Do not list overridden plugin names in --version diff --git a/tests/external_plugins_src/jrnl/contrib/exporter/testing.py b/tests/external_plugins_src/jrnl/contrib/exporter/flag.py similarity index 91% rename from tests/external_plugins_src/jrnl/contrib/exporter/testing.py rename to tests/external_plugins_src/jrnl/contrib/exporter/flag.py index 92941eb6..a7b1c6a2 100644 --- a/tests/external_plugins_src/jrnl/contrib/exporter/testing.py +++ b/tests/external_plugins_src/jrnl/contrib/exporter/flag.py @@ -6,6 +6,8 @@ """ Exporter for testing and experimentation purposes. +It is not called "testing" because then it's not installed. + The presence of this plugin is also used as a "switch" by the test suite to decide on whether or not to run the "vanilla" test suite, or the test suite for external plugins. diff --git a/tests/external_plugins_src/jrnl/contrib/importer/.gitkeep b/tests/external_plugins_src/jrnl/contrib/importer/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/external_plugins_src/jrnl/contrib/importer/sample_json.py b/tests/external_plugins_src/jrnl/contrib/importer/simple_json.py similarity index 100% rename from tests/external_plugins_src/jrnl/contrib/importer/sample_json.py rename to tests/external_plugins_src/jrnl/contrib/importer/simple_json.py