From 0ac0f962e3b2f475006873410aef3f7a0a4e545b Mon Sep 17 00:00:00 2001 From: moi15moi <80980684+moi15moi@users.noreply.github.com> Date: Mon, 27 Jan 2025 09:01:26 -0500 Subject: [PATCH 1/3] Add support for coverage --- .github/workflows/autotest.yml | 5 ++++- pyproject.toml | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/autotest.yml b/.github/workflows/autotest.yml index 13c1b73ad..7240d3aae 100644 --- a/.github/workflows/autotest.yml +++ b/.github/workflows/autotest.yml @@ -33,7 +33,10 @@ jobs: pip install 'numpy<2' pip install pywin32 } - python -m unittest discover -v -s ./comtypes/test -t comtypes\test + pip install coverage[toml] + coverage run -m unittest discover -v -s comtypes\test -t comtypes\test + - name: Run coverage report + run: coverage report - name: Unregister the OutProc COM server run: | cd source/CppTestSrv diff --git a/pyproject.toml b/pyproject.toml index 2e3adc1d8..10ea8040c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,3 +40,9 @@ ignore = ["E402"] "comtypes/test/test_subinterface.py" = ["E401", "F401", "F403", "F405"] "comtypes/test/test_urlhistory.py" = ["E401", "F401", "F403", "F405", "F841"] "comtypes/test/test_variant.py" = ["F401", "F821", "F841"] + +[tool.coverage.run] +# Specify the source directory to avoid tracking temporary files created by "test_client_regenerate_modules.py". +# Without this, coverage track these temporary files, leading to error when trying to generate a report. +source = ["comtypes"] +omit = ["comtypes/gen/*"] From 637c906fe415c03f157222256e1b6ab3fc8ea33e Mon Sep 17 00:00:00 2001 From: moi15moi <80980684+moi15moi@users.noreply.github.com> Date: Thu, 30 Jan 2025 19:10:30 -0500 Subject: [PATCH 2/3] [pyproject.toml] Ignore test folder for coverage --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 10ea8040c..4a7bc9862 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,4 +45,4 @@ ignore = ["E402"] # Specify the source directory to avoid tracking temporary files created by "test_client_regenerate_modules.py". # Without this, coverage track these temporary files, leading to error when trying to generate a report. source = ["comtypes"] -omit = ["comtypes/gen/*"] +omit = ["comtypes/gen/*", "comtypes/test/*"] From 6e405dd343aa7deadb6309985739f9b9f706c711 Mon Sep 17 00:00:00 2001 From: moi15moi <80980684+moi15moi@users.noreply.github.com> Date: Thu, 30 Jan 2025 21:20:13 -0500 Subject: [PATCH 3/3] test_eval replace "(1, 2, 3)" with "1 + 2" --- comtypes/test/test_comserver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/comtypes/test/test_comserver.py b/comtypes/test/test_comserver.py index 3c4994411..688683039 100644 --- a/comtypes/test/test_comserver.py +++ b/comtypes/test/test_comserver.py @@ -94,9 +94,9 @@ def test_eval(self): obj = self.create_object() def func(): - return obj.eval("(1, 2, 3)") + return obj.eval("1 + 2") - self.assertEqual(func(), (1, 2, 3)) # type: ignore + self.assertEqual(func(), 3) # type: ignore self._find_memleak(func) def test_get_typeinfo(self):