Skip to content

Commit

Permalink
Add xdoctest (#141)
Browse files Browse the repository at this point in the history
* Add xdoctest

* Added requirements for coverage
  • Loading branch information
Erotemic authored Nov 19, 2024
1 parent 4a6015a commit baa133f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
pip install -r requirements/tests.txt
- name: Run unittests
run: |
pytest test/unittests
pytest --cov-config pyproject.toml --cov-report html --cov-report term --durations 5 --cov=ovos_dinkum_listener
7 changes: 7 additions & 0 deletions ovos_dinkum_listener/voice_loop/hotwords.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ class HotWordException(RuntimeWarning):


class CyclicAudioBuffer:
"""
Example:
>>> from ovos_dinkum_listener.voice_loop.hotwords import * # NOQA
>>> self = CyclicAudioBuffer()
>>> self.append(b'hello-world')
>>> print(len(self.get()))
"""
def __init__(self, duration=0.98, initial_data=None,
sample_rate=16000, sample_width=2):
self.size = self.duration_to_bytes(duration, sample_rate, sample_width)
Expand Down
38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = [ "setuptools>=41.0.1",]
build-backend = "setuptools.build_meta"

[tool.mypy]
ignore_missing_imports = true

[tool.pytest.ini_options]
addopts = "--xdoctest --ignore-glob=setup.py"
norecursedirs = ".git build __pycache__ docs"
filterwarnings = [ "default", ]

[tool.coverage.run]
branch = true
source = ["ovos_dinkum_listener"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
".* # pragma: no cover",
".* # nocover",
"def __repr__",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if trace is not None",
"verbose = .*",
"^ *raise",
"^ *pass *$",
"if _debug:",
"if __name__ == .__main__.:",
]
omit = [
"*/setup.py",
]

[tool.xdoctest]
options = ''
5 changes: 4 additions & 1 deletion requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
pytest~=7.1
ovos-vad-plugin-webrtcvad
ovos-vad-plugin-webrtcvad
xdoctest~=1.1.5
pytest-cov>=3.0.0
coverage>=7.2.7
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#
import os
import os.path
from pathlib import Path

from setuptools import setup

Expand Down

0 comments on commit baa133f

Please sign in to comment.