From 7b4a0bafb670fb51c061c4f0297a21d05b5fe5db Mon Sep 17 00:00:00 2001 From: Floyd Hightower Date: Mon, 26 Apr 2021 06:43:52 -0400 Subject: [PATCH 1/4] Removing pycharm docs if app does not use pycharm --- {{cookiecutter.project_slug}}/docs/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/{{cookiecutter.project_slug}}/docs/index.rst b/{{cookiecutter.project_slug}}/docs/index.rst index 5fafc696..cb4cbaed 100644 --- a/{{cookiecutter.project_slug}}/docs/index.rst +++ b/{{cookiecutter.project_slug}}/docs/index.rst @@ -10,8 +10,8 @@ Welcome to {{ cookiecutter.project_name }}'s documentation! :maxdepth: 2 :caption: Contents: - howto - pycharm/configuration + howto{% if cookiecutter.use_pycharm == 'y' %} + pycharm/configuration{% endif %} users From 6b5ad4e8336d30b2b69b3053403b590c638a573d Mon Sep 17 00:00:00 2001 From: Floyd Hightower Date: Mon, 26 Apr 2021 06:17:02 -0500 Subject: [PATCH 2/4] Adding test to validate pycharm docs are removed appropriately --- tests/test_cookiecutter_generation.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index 7e585ea4..cbe3324a 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -282,3 +282,20 @@ def test_error_if_incompatible(cookies, context, invalid_context): assert result.exit_code != 0 assert isinstance(result.exception, FailedHookException) + + +@pytest.mark.parametrize( + ["use_pycharm", "pycharm_docs_exist"], + [ + ("n", False), + ("y", True), + ], +) +def test_pycharm_docs_removed(cookies, context, use_pycharm, pycharm_docs_exist): + """.""" + context.update({"use_pycharm": use_pycharm}) + result = cookies.bake(extra_context=context) + + with open(f"{result.project}/docs/index.rst", "r") as f: + has_pycharm_docs = 'pycharm/configuration' in f.read() + assert has_pycharm_docs == pycharm_docs_exist From 6f66b330e659c252cf49ed772fee9c1bf334d3dd Mon Sep 17 00:00:00 2001 From: Floyd Hightower Date: Tue, 27 Apr 2021 05:41:00 -0500 Subject: [PATCH 3/4] Running black on updated file --- tests/test_cookiecutter_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index cbe3324a..f62d4bc9 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -297,5 +297,5 @@ def test_pycharm_docs_removed(cookies, context, use_pycharm, pycharm_docs_exist) result = cookies.bake(extra_context=context) with open(f"{result.project}/docs/index.rst", "r") as f: - has_pycharm_docs = 'pycharm/configuration' in f.read() + has_pycharm_docs = "pycharm/configuration" in f.read() assert has_pycharm_docs == pycharm_docs_exist From b7de132d31e94832757ccf4770d5a7685e54c8e3 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sat, 11 Sep 2021 17:48:47 +0100 Subject: [PATCH 4/4] Compare boolean with is instead of equality --- tests/test_cookiecutter_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cookiecutter_generation.py b/tests/test_cookiecutter_generation.py index f62d4bc9..295e9c5f 100755 --- a/tests/test_cookiecutter_generation.py +++ b/tests/test_cookiecutter_generation.py @@ -298,4 +298,4 @@ def test_pycharm_docs_removed(cookies, context, use_pycharm, pycharm_docs_exist) with open(f"{result.project}/docs/index.rst", "r") as f: has_pycharm_docs = "pycharm/configuration" in f.read() - assert has_pycharm_docs == pycharm_docs_exist + assert has_pycharm_docs is pycharm_docs_exist