From d12b63dffb95e919ca70e52667bdd2f8b13f1ed2 Mon Sep 17 00:00:00 2001 From: Faruk D Date: Thu, 29 Apr 2021 17:19:23 +0200 Subject: [PATCH 1/9] fix pep8 linting issue --- .../{{cookiecutter.package_name}}/my_module.py | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py b/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py index 3479f21b..946ad732 100644 --- a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py @@ -4,6 +4,7 @@ logger = logging.getLogger(__name__) + # FIXME: put actual code here def example(): logger.info("Providing information about the excecution of the function.") From 228046bdd56e8532ccceea1785bd8e53fe9fa214 Mon Sep 17 00:00:00 2001 From: Faruk D Date: Thu, 29 Apr 2021 17:27:13 +0200 Subject: [PATCH 2/9] fix unused __version__ issue --- .../{{cookiecutter.package_name}}/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py b/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py index 418484ea..b36010b6 100644 --- a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py @@ -7,3 +7,4 @@ __author__ = "{{ cookiecutter.full_name }}" __email__ = "{{ cookiecutter.email }}" +__version__ = __version__ From 046b99671c1be20c87f8dc59ec8850bfffc1c58d Mon Sep 17 00:00:00 2001 From: Faruk D Date: Thu, 29 Apr 2021 19:05:52 +0200 Subject: [PATCH 3/9] add module import test to fix pyflakes issue --- {{cookiecutter.project_name}}/tests/test_my_module.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/{{cookiecutter.project_name}}/tests/test_my_module.py b/{{cookiecutter.project_name}}/tests/test_my_module.py index 9e355f70..7161502e 100644 --- a/{{cookiecutter.project_name}}/tests/test_my_module.py +++ b/{{cookiecutter.project_name}}/tests/test_my_module.py @@ -6,6 +6,10 @@ from {{ cookiecutter.package_name }} import my_module +def test_module_import(): + assert my_module not in sys.modules + + def test_something(): assert True From fa396ab889557b4458fa775f5d4831478448424a Mon Sep 17 00:00:00 2001 From: Faruk D Date: Thu, 29 Apr 2021 19:09:41 +0200 Subject: [PATCH 4/9] add log capture test to increase coverage --- {{cookiecutter.project_name}}/tests/test_my_module.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/{{cookiecutter.project_name}}/tests/test_my_module.py b/{{cookiecutter.project_name}}/tests/test_my_module.py index 7161502e..25ca9163 100644 --- a/{{cookiecutter.project_name}}/tests/test_my_module.py +++ b/{{cookiecutter.project_name}}/tests/test_my_module.py @@ -4,6 +4,16 @@ """ import pytest from {{ cookiecutter.package_name }} import my_module +from testfixtures import LogCapture + + +def test_log_capture(caplog): + with LogCapture() as lc: + my_module.example() + + lc.check( + ('{{ cookiecutter.package_name }}.my_module', 'INFO', 'Providing information about the excecution of the function.') + ) def test_module_import(): From 13eb7a9067e5cffb769f75a27d89ca562655ede1 Mon Sep 17 00:00:00 2001 From: Faruk D Date: Thu, 29 Apr 2021 19:12:56 +0200 Subject: [PATCH 5/9] add testfixtures dependency for log capture test --- {{cookiecutter.project_name}}/setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_name}}/setup.cfg b/{{cookiecutter.project_name}}/setup.cfg index 78975cd2..b4ef67f6 100644 --- a/{{cookiecutter.project_name}}/setup.cfg +++ b/{{cookiecutter.project_name}}/setup.cfg @@ -56,6 +56,7 @@ dev = sphinx sphinx_rtd_theme recommonmark + testfixtures publishing = twine wheel From ad0cffb70b6e336c8ba83b2f8e6f462a9f1bb45f Mon Sep 17 00:00:00 2001 From: Faruk D Date: Thu, 29 Apr 2021 19:16:07 +0200 Subject: [PATCH 6/9] increase verbosity of pytest --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a15487cf..78a05a7b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,4 +32,4 @@ jobs: python3 -m pip install .[dev] - name: Run pytest run: | - pytest + pytest -v From 1b583965fb241bd9aa60e747d4f0be6c7d11e37a Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 13:17:13 +0200 Subject: [PATCH 7/9] change example fucntion and update the test --- {{cookiecutter.project_name}}/setup.cfg | 1 - .../tests/test_my_module.py | 14 ++------------ .../{{cookiecutter.package_name}}/my_module.py | 9 ++------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/{{cookiecutter.project_name}}/setup.cfg b/{{cookiecutter.project_name}}/setup.cfg index b4ef67f6..78975cd2 100644 --- a/{{cookiecutter.project_name}}/setup.cfg +++ b/{{cookiecutter.project_name}}/setup.cfg @@ -56,7 +56,6 @@ dev = sphinx sphinx_rtd_theme recommonmark - testfixtures publishing = twine wheel diff --git a/{{cookiecutter.project_name}}/tests/test_my_module.py b/{{cookiecutter.project_name}}/tests/test_my_module.py index 25ca9163..76922037 100644 --- a/{{cookiecutter.project_name}}/tests/test_my_module.py +++ b/{{cookiecutter.project_name}}/tests/test_my_module.py @@ -4,20 +4,10 @@ """ import pytest from {{ cookiecutter.package_name }} import my_module -from testfixtures import LogCapture -def test_log_capture(caplog): - with LogCapture() as lc: - my_module.example() - - lc.check( - ('{{ cookiecutter.package_name }}.my_module', 'INFO', 'Providing information about the excecution of the function.') - ) - - -def test_module_import(): - assert my_module not in sys.modules +def test_hello(): + assert my_module.hello('nlesc') == 'Hello nlesc!' def test_something(): diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py b/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py index 946ad732..c0d5ce25 100644 --- a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/my_module.py @@ -1,10 +1,5 @@ """Documentation about the {{ cookiecutter.package_name }} module.""" -import logging - - -logger = logging.getLogger(__name__) - # FIXME: put actual code here -def example(): - logger.info("Providing information about the excecution of the function.") +def hello(name): + return f'Hello {name}!' From 2a48af96eb2639d6827229156c12e59d373e8194 Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 13:18:34 +0200 Subject: [PATCH 8/9] remove assignment of version --- .../{{cookiecutter.package_name}}/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py b/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py index b36010b6..418484ea 100644 --- a/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py +++ b/{{cookiecutter.project_name}}/{{cookiecutter.package_name}}/__init__.py @@ -7,4 +7,3 @@ __author__ = "{{ cookiecutter.full_name }}" __email__ = "{{ cookiecutter.email }}" -__version__ = __version__ From 031447e5bb1a9b93ae380f92dfe32f001ba8d640 Mon Sep 17 00:00:00 2001 From: Faruk D Date: Mon, 3 May 2021 13:21:50 +0200 Subject: [PATCH 9/9] update number of tests --- tests/test_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_project.py b/tests/test_project.py index 444e8b6c..f38bdc75 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -40,7 +40,7 @@ def test_pytest(baked_with_development_dependencies): project_dir, env_bin = baked_with_development_dependencies pytest_output = run([f'{env_bin}pytest'], project_dir) assert pytest_output.returncode == 0 - assert '== 3 passed in' in pytest_output.stdout + assert '== 4 passed in' in pytest_output.stdout assert (project_dir / 'coverage.xml').exists() assert (project_dir / 'htmlcov/index.html').exists()