Repository: dh-tech/undate-python (language: python)

Issue:
Setup code coverage 



Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index ac92542..0406c69 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,7 @@ venv/
 ENV/
 env.bak/
 venv.bak/
+
+# code coverage
+.coverage
+coverage.xml
diff --git a/README.md b/README.md
index 171c31f..bf17c0e 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,7 @@ Repository for the DHTech 2022 Hackathon
 
 [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
 [![unit tests](https://github.com/dh-tech/hackathon-2022/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/dh-tech/hackathon-2022/actions/workflows/unit_tests.yml)
+[![codecov](https://codecov.io/gh/dh-tech/hackathon-2022/branch/main/graph/badge.svg?token=GE7HZE8C9D)](https://codecov.io/gh/dh-tech/hackathon-2022)
 [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
 <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
 [![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
diff --git a/setup.cfg b/setup.cfg
index a68074c..d9e416e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -39,7 +39,9 @@ dev =
   tox
   sphinx
   twine
-test = 
+  wheel
+  pytest-cov
+test =
   pytest>=7.2
 
 [options.packages.find]
diff --git a/tox.ini b/tox.ini
index fd54c10..cb8a73e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -27,6 +27,13 @@ deps =
 commands =
     flake8 --ignore=E501,E402,F401 src/undate/ tests/
 
+[testenv:coverage]
+deps =
+    pytest
+    pytest-cov
+commands =
+    pytest --cov=./ --cov-report=xml
+
 [testenv:docs]
 description = invoke sphinx-build to build the HTML docs
 basepython = python3.10


Test patch:
diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml
index d492d39..70b0c63 100644
--- a/.github/workflows/unit_tests.yml
+++ b/.github/workflows/unit_tests.yml
@@ -9,6 +9,9 @@ on:
       - 'tests/**'
   pull_request:
 
+env:
+  COV_PYTHON_VERSION: "3.9"
+
 jobs:
   python-unit:
     runs-on: ubuntu-latest
@@ -32,5 +35,17 @@ jobs:
           pip install -e ".[dev]"
           python -m pip install tox tox-gh-actions
         if: steps.python-cache.outputs.cache-hit != 'true'
-      - name: Run unit tests
+
+      # for all versions but the one we use for code coverage, run normally
+      - name: Run unit tests normally
         run: tox
+        if: ${{ matrix.python != env.COV_PYTHON_VERSION }}
+
+      # run code coverage in one version only
+      - name: Run unit tests with code coverage reporting
+        run: tox -e coverage
+        if: ${{ matrix.python == env.COV_PYTHON_VERSION }}
+      - name: Upload test coverage to Codecov
+        uses: codecov/codecov-action@v3
+        if: ${{ matrix.python == env.COV_PYTHON_VERSION }}
+
diff --git a/tests/test_dateformat/test_base.py b/tests/test_dateformat/test_base.py
index e36fe26..16f0486 100644
--- a/tests/test_dateformat/test_base.py
+++ b/tests/test_dateformat/test_base.py
@@ -1,3 +1,5 @@
+import pytest
+
 from undate.dateformat.base import BaseDateFormat
 
 
@@ -26,3 +28,11 @@ def test_formatters_are_unique(self):
         #     name = "ISO8601"
 
         # assert len(BaseDateFormat.available_formatters()) != len(BaseDateFormat.__subclasses__())
+
+    def test_parse_not_implemented(self):
+        with pytest.raises(NotImplementedError):
+            BaseDateFormat().parse("foo bar baz")
+
+    def test_parse_to_string(self):
+        with pytest.raises(NotImplementedError):
+            BaseDateFormat().to_string(1991)