Skip to content

Fix Unit Tests and create a GitHub Actions CI Pipeline to run them #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: unit tests

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["pypy3.10", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest coverage
- name: Test with pyment
run: |
coverage run --source pyment -m pytest -s tests
- name: Generate Coverage Report
run: |
coverage report
20 changes: 16 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Project Status

**Test Status**

Linux: |travis|
Linux: |github|

Windows: |appveyor|


.. |travis| image:: https://travis-ci.org/dadadel/pyment.svg?branch=master
:target: https://travis-ci.org/dadadel/pyment.svg?branch=master
:alt: Linux tests (TravisCI)
.. |github| image:: https://github.com/dadadel/pyment/actions/workflows/run_tests.yml/badge.svg
:target: https://github.com/dadadel/pyment/actions/workflows/run_tests.yml/badge.svg
:alt: Linux tests (Github Actions)

.. |appveyor| image:: https://ci.appveyor.com/api/projects/status/f9d4jps5fkf4m42h?svg=true
:target: https://ci.appveyor.com/api/projects/status/f9d4jps5fkf4m42h?svg=true
Expand All @@ -39,6 +39,18 @@ Windows: |appveyor|
.. image:: https://img.shields.io/badge/python-3.9-blue.svg
:target: https://img.shields.io/badge/python-3.9-blue.svg
:alt: Supports Python39
.. image:: https://img.shields.io/badge/python-3.10-blue.svg
:target: https://img.shields.io/badge/python-3.10-blue.svg
:alt: Supports Python310
.. image:: https://img.shields.io/badge/python-3.11-blue.svg
:target: https://img.shields.io/badge/python-3.11-blue.svg
:alt: Supports Python311
.. image:: https://img.shields.io/badge/python-3.12-blue.svg
:target: https://img.shields.io/badge/python-3.12-blue.svg
:alt: Supports Python312
.. image:: https://img.shields.io/badge/python-3.13-blue.svg
:target: https://img.shields.io/badge/python-3.13-blue.svg
:alt: Supports Python313

|

Expand Down
2 changes: 1 addition & 1 deletion pyment/docstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ class GoogledocTools(DocToolsBase):
""" """
def __init__(self,
first_line=None,
optional_sections=('raise'),
optional_sections=('raise',),
excluded_sections=()):
"""
:param first_line: indicate if description should start
Expand Down
2 changes: 1 addition & 1 deletion tests/issue51.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def foo():
Returns:

Raises:
test
test

"""
pass
4 changes: 2 additions & 2 deletions tests/issue88.py.patch
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

async def async_func3(param1, param2=None):
- """
- somme comment
+ """somme comment
- some comment
+ """some comment
+
:param param1: my parameter 1
- :param param2: my second param
Expand Down
12 changes: 4 additions & 8 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def func():
Args:

Returns:
ret type: smthg

Raises:
ret type: smthg

"""
pass
Expand All @@ -64,7 +62,7 @@ def func():

--- a/-
+++ b/-
@@ -3,9 +3,12 @@
@@ -3,9 +3,10 @@
def func():
"""First line

Expand All @@ -73,9 +71,7 @@ def func():

- :rtype: ret type
+ Returns:
+ ret type: smthg
+
+ Raises:
+ ret type: smthg


"""
Expand Down Expand Up @@ -224,7 +220,7 @@ def testNoArgs_ge_py33(self):
write_to_stdin=None,
# expected_stderr=re.compile('too few arguments'),
expected_stderr=re.compile(
r'usage: pymentapp.py \[-h\] \[-i style\] \[-o style\] \[-q quotes\] \[-f status\] \[-t\].?.?\s{20}\[-c config\] \[-d\] \[-p status\] \[-v\] \[-w\].?.?\s{20}path.?.?pymentapp\.py: error: the following arguments are required: path',
r'usage: pymentapp.py \[-h\] \[-i style\] \[-o style\] \[-q quotes\] \[-f status\] \[-t\].?.?\s{20}\[-c config\] \[-d\] \[-p status\] \[-v\] \[-w\] \[-s spaces\] \[-e\].?.?\s{20}path.?.?pymentapp\.py: error: the following arguments are required: path',
re.DOTALL),
expected_returncode=2
)
Expand Down
1 change: 0 additions & 1 deletion tests/test_pyment_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def testCaseGenAllParamsReST(self):
result = ''.join(p.diff())
self.assertTrue(remove_diff_header(result) == remove_diff_header(expected))

@unittest.expectedFailure
def testCaseGenAllParamsGoogle(self):
# The file has several functions with no or several parameters,
# so Pyment should produce docstrings in google format
Expand Down