Skip to content

Commit

Permalink
Bumped version and minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paebbels committed Jan 14, 2024
1 parent 55d520f commit 0cdf4ae
Show file tree
Hide file tree
Showing 17 changed files with 858 additions and 69 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/Pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Pipeline
on:
push:
workflow_dispatch:
schedule:
# Every Friday at 22:00 - rerun pipeline to check for dependency-based issues
- cron: '0 22 * * 5'

jobs:
UnitTestingParams:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ details.

```Python
# ==============================================================================
# Sphinx-reports - DocCov
# Sphinx-reports - CodeCov
# ==============================================================================
report_codecov_packages = {
"src": {
Expand Down
2 changes: 1 addition & 1 deletion doc/CodeCov/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ See the :ref:`overview page <OVER>` on how to setup and enable the Sphinx extens
.. code-block:: Python
# ==============================================================================
# Sphinx-reports - DocCov
# Sphinx-reports - CodeCov
# ==============================================================================
report_codecov_packages = {
"src": {
Expand Down
8 changes: 6 additions & 2 deletions doc/Unittest/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
Unit Test Summary
#################

🚧 This is a planned feature. 🚧
🚧 This is a work-in-progress feature. 🚧

.. #:term:`Unittests` checks if a source code was used during execution. Usually, testcases are run by a testcase
execution framework like `pytest <https://github.com/pytest-dev/pytest>`__.

.. rubric:: Supported report generators

* `pytest <https://github.com/pytest-dev/pytest>`__


.. _UNITTEST/Quick:

Expand All @@ -31,7 +35,7 @@ See the :ref:`overview page <OVER>` on how to setup and enable the Sphinx extens
.. code-block:: Python
# ==============================================================================
# Sphinx-reports - DocCov
# Sphinx-reports - Unittest
# ==============================================================================
report_codecov_packages = {
"src": {
Expand Down
7 changes: 2 additions & 5 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@


# ==============================================================================
# Sphinx-reports - DocCov
# Sphinx-reports
# ==============================================================================
_coverageLevels = {
30: {"class": "report-cov-below30", "desc": "almost undocumented"},
Expand All @@ -271,10 +271,7 @@
}

report_unittest_testsuites = {
"src": {
"name": "sphinx_reports",
"xml_report": "../report/unit/TestReportSummary.xml",
}
"src": {"xml_report": "../report/unit/unittest.xml"},
}
report_codecov_packages = {
"src": {
Expand Down
39 changes: 20 additions & 19 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,28 @@ Supported Report Formats

Supported format reports are:

* ✅ Documentation coverage (by `docstr_coverage <https://github.com/HunterMcGushion/docstr_coverage>`__ (or `interrogate`?))
* ✅🚧 Unit Test summaries (by `pytest <https://github.com/pytest-dev/pytest>`__)

* ✅ Summary page (displaying `unittest.xml`)
* 🚧 Show logging, output and error messages.

* 🚧 Code coverage (by `Coverage.py <https://github.com/nedbat/coveragepy/tree/master>`__)

* ✅ Summary page
* 🚧 Highlighted source code

* ✅🚧 Unit Test summaries (by `pytest <https://github.com/pytest-dev/pytest>`__)
* ✅ Documentation coverage (by `docstr_coverage <https://github.com/HunterMcGushion/docstr_coverage>`__ (or `interrogate`?))
* 🚧 Dependencies (reading `requirements.txt` files)

* ✅ Summary page (displaying `unittest.xml`)
* 🚧 Show logging, output and error messages.

* 🚧 Dependencies (reading `requirements.txt` files)
Unit Test Summary
=================

Documentation coverage
======================
🚧 This is a work-in-progress feature. 🚧

:ref:`DOCCOV` counts how many publicly accessible members are documented using a Python :term:`doc-string`. Based on the
count of possibly documented public members and the actual number of non-empty *doc-strings*, a percentage of
documentation coverage can be computed.
:ref:`UNITTEST`

.. todo:: index: Screen shot here and link to this documentations report.
.. todo:: index: Screen shot here and link to this unitest summary.


Code Coverage
Expand All @@ -117,14 +118,14 @@ coverage collection using the ``pytest-cov`` plugin. For Python, coverage collec
.. todo:: index: Screen shot here and link to this code coverage report.


Unit Test Summary
=================

🚧 This is a work-in-progress feature. 🚧
Documentation coverage
======================

:ref:`UNITTEST`
:ref:`DOCCOV` counts how many publicly accessible members are documented using a Python :term:`doc-string`. Based on the
count of possibly documented public members and the actual number of non-empty *doc-strings*, a percentage of
documentation coverage can be computed.

.. todo:: index: Screen shot here and link to this unitest summary.
.. todo:: index: Screen shot here and link to this documentations report.


Dependencies
Expand Down Expand Up @@ -178,9 +179,9 @@ License
:hidden:

Overview
DocCov/index
CodeCov/index
Unittest/index
CodeCov/index
DocCov/index

.. raw:: latex

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ filterwarnings = [
"error::PendingDeprecationWarning"
]
junit_logging = "all"
junit_suite_name = "sphinx_reports"

[tool.interrogate]
color = true
Expand Down
2 changes: 1 addition & 1 deletion run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if ($install)
{ Write-Host -ForegroundColor Cyan "[ADMIN][UNINSTALL] Uninstalling $PackageName ..."
py -3.12 -m pip uninstall -y $PackageName
Write-Host -ForegroundColor Cyan "[ADMIN][INSTALL] Installing $PackageName from wheel ..."
py -3.12 -m pip install .\dist\$PackageName-0.5.0-py3-none-any.whl
py -3.12 -m pip install .\dist\$PackageName-0.6.0-py3-none-any.whl

Write-Host -ForegroundColor Cyan "[ADMIN][INSTALL] Closing window in 5 seconds ..."
Start-Sleep -Seconds 5
Expand Down
20 changes: 4 additions & 16 deletions sphinx_reports/Adapter/JUnit.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,15 @@ class UnittestError(ReportExtensionError):

@export
class Analyzer:
_packageName: str
_reportFile: Path
_documentElement: Element
_testsuiteSummary: TestsuiteSummary

def __init__(self, packageName: str, reportFile: Path):
self._packageName = packageName
def __init__(self, reportFile: Path):
self._reportFile = reportFile

if not self._reportFile.exists():
# not found vs. does not exist
# FIXME: not found vs. does not exist
# text in inner exception needed?
# FileNotFoundError(f"File '{self._path!s}' not found.")
raise UnittestError(f"JUnit unittest report file '{self._reportFile}' not found.") from FileNotFoundError(self._reportFile)
Expand All @@ -79,7 +77,6 @@ def _ParseRootElement(self, root: Element) -> None:
for rootNode in root.childNodes:
if rootNode.nodeName == "testsuite":
self._ParseTestsuite(rootNode)
# testsuite._testsuites[ts._name] = ts

def _ParseTestsuite(self, testsuitesNode: Element) -> None:
for node in testsuitesNode.childNodes:
Expand All @@ -89,28 +86,19 @@ def _ParseTestsuite(self, testsuitesNode: Element) -> None:
elif node.tagName == "testcase":
self._ParseTestcase(node)

# testsuite._testcases[tc._name] = tc

def _ParseTestcase(self, testsuiteNode: Element) -> None:
className = testsuiteNode.getAttribute("classname")
name = testsuiteNode.getAttribute("name")

concurrentSuite = self._testsuiteSummary

testsuitePath = className.split(".")
for testsuiteName in testsuitePath[:-1]:
for testsuiteName in testsuitePath:
try:
concurrentSuite = concurrentSuite[testsuiteName]
except KeyError:
new = Testsuite(testsuiteName)
concurrentSuite._testsuites[testsuiteName] = new
concurrentSuite = new

testcaseName = testsuitePath[-1]
try:
testcase = concurrentSuite[testcaseName]
except KeyError:
testcase = Testcase(testcaseName)
concurrentSuite._testcases[testcaseName] = testcase

testcase._tests[name] = Test(name)
concurrentSuite._testcases[name] = Testcase(name)
26 changes: 4 additions & 22 deletions sphinx_reports/Unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@


class report_DictType(TypedDict):
name: str
xml_report: str


Expand All @@ -68,8 +67,6 @@ class UnittestSummary(BaseDirective):
} #: A dictionary of all configuration values used by this domain. (name: (default, rebuilt, type))

_reportID: str
_legend: LegendPosition
_packageName: str
_xmlReport: Path
_testsuite: TestsuiteSummary

Expand All @@ -91,11 +88,6 @@ def _CheckConfiguration(self) -> None:
except KeyError as ex:
raise ReportExtensionError(f"conf.py: {ReportDomain.name}_{self.configPrefix}_testsuites: No configuration found for '{self._reportID}'.") from ex

try:
self._packageName = testsuiteConfiguration["name"]
except KeyError as ex:
raise ReportExtensionError(f"conf.py: {ReportDomain.name}_{self.configPrefix}_testsuites:{self._reportID}.name: Configuration is missing.") from ex

try:
self._xmlReport = Path(testsuiteConfiguration["xml_report"])
except KeyError as ex:
Expand Down Expand Up @@ -124,24 +116,14 @@ def sortedValues(d: Mapping[str, Testsuite]) -> Generator[Testsuite, None, None]
for key in sorted(d.keys()):
yield d[key]

def renderRoot(tableBody: nodes.tbody, testsuite: TestsuiteSummary, level: int = 0) -> None:
tableBody += nodes.row(
"",
nodes.entry("", nodes.paragraph(text=f"{'  '*level}{testsuite.Name}")),
nodes.entry("", nodes.paragraph(text=f"")), # {testsuite.Expected}")),
nodes.entry("", nodes.paragraph(text=f"")), # {testsuite.Covered}")),
nodes.entry("", nodes.paragraph(text=f"")), # {testsuite.Uncovered}")),
nodes.entry("", nodes.paragraph(text=f"")), # {testsuite.Coverage:.1%}")),
classes=["report-unittest-table-row"],
)

def renderRoot(tableBody: nodes.tbody, testsuite: TestsuiteSummary) -> None:
for ts in sortedValues(testsuite._testsuites):
renderTestsuite(tableBody, ts, level + 1)
renderTestsuite(tableBody, ts, 0)

def renderTestsuite(tableBody: nodes.tbody, testsuite: Testsuite, level: int) -> None:
tableBody += nodes.row(
"",
nodes.entry("", nodes.paragraph(text=f"{'  '*level}{testsuite.Name}")),
nodes.entry("", nodes.paragraph(text=f"{'  '*level}{testsuite.Name}")),
nodes.entry("", nodes.paragraph(text=f"")), # {testsuite.Expected}")),
nodes.entry("", nodes.paragraph(text=f"")), # {testsuite.Covered}")),
nodes.entry("", nodes.paragraph(text=f"")), # {testsuite.Uncovered}")),
Expand Down Expand Up @@ -199,7 +181,7 @@ def run(self) -> List[nodes.Node]:
self._CheckConfiguration()

# Assemble a list of Python source files
analyzer = Analyzer(self._packageName, self._xmlReport)
analyzer = Analyzer(self._xmlReport)
self._testsuite = analyzer.Convert()
# self._testsuite.Aggregate()

Expand Down
2 changes: 1 addition & 1 deletion sphinx_reports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
__email__ = "[email protected]"
__copyright__ = "2023-2024, Patrick Lehmann"
__license__ = "Apache License, Version 2.0"
__version__ = "0.5.0"
__version__ = "0.6.0"
__keywords__ = ["Python3", "Sphinx", "Extension", "Report", "doc-string", "interrogate"]

from hashlib import md5
Expand Down
Loading

0 comments on commit 0cdf4ae

Please sign in to comment.