Skip to content

Commit fb6f053

Browse files
committed
Add tests
1 parent 5ac923e commit fb6f053

File tree

22 files changed

+1313
-14
lines changed

22 files changed

+1313
-14
lines changed

.github/workflows/python_ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,11 @@ jobs:
6666
- name: "Run Tests for Python ${{ matrix.config.python-version }}"
6767
if: steps.setup-python.outcome == 'success'
6868
run: python -m tox -e "${{ matrix.config.testenvs }}" -s false
69+
70+
- name: "Upload Coverage 🚀"
71+
uses: actions/upload-artifact@v4
72+
if: ${{ always() && steps.setup-python.outcome == 'success' }}
73+
with:
74+
name: "coverage-${{ matrix.config.python-version }}"
75+
path: .coverage
76+
include-hidden-files: true

.github/workflows/python_ci_linux.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,72 @@ jobs:
6363
python -m site
6464
python -m pip install --upgrade pip setuptools wheel
6565
python -m pip install --upgrade tox~=3.0 virtualenv!=20.16.0
66+
python -m pip install --upgrade coverage_pyver_pragma
6667
6768
- name: "Run Tests for Python ${{ matrix.config.python-version }}"
6869
if: steps.setup-python.outcome == 'success'
6970
run: python -m tox -e "${{ matrix.config.testenvs }}" -s false
7071

72+
- name: "Upload Coverage 🚀"
73+
uses: actions/upload-artifact@v4
74+
if: ${{ always() && steps.setup-python.outcome == 'success' }}
75+
with:
76+
name: "coverage-${{ matrix.config.python-version }}"
77+
path: .coverage
78+
include-hidden-files: true
79+
80+
81+
Coverage:
82+
needs: tests
83+
permissions:
84+
actions: write
85+
contents: read
86+
runs-on: "ubuntu-22.04"
87+
steps:
88+
- name: Checkout 🛎️
89+
uses: "actions/checkout@v4"
90+
91+
- name: Setup Python 🐍
92+
uses: "actions/setup-python@v5"
93+
with:
94+
python-version: 3.8
95+
96+
- name: Install dependencies 🔧
97+
run: |
98+
python -m pip install --upgrade pip setuptools wheel
99+
python -m pip install --upgrade "coveralls>=3.0.0" coverage_pyver_pragma
100+
101+
- name: "Download Coverage 🪂"
102+
uses: actions/download-artifact@v4
103+
with:
104+
path: coverage
105+
106+
- name: Display structure of downloaded files
107+
id: show
108+
run: ls -R
109+
working-directory: coverage
110+
continue-on-error: true
71111

112+
- name: Combine Coverage 👷
113+
if: ${{ steps.show.outcome != 'failure' }}
114+
run: |
115+
shopt -s globstar
116+
python -m coverage combine coverage/**/.coverage
117+
118+
- name: "Upload Combined Coverage Artefact 🚀"
119+
if: ${{ steps.show.outcome != 'failure' }}
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: "combined-coverage"
123+
path: .coverage
124+
include-hidden-files: true
125+
126+
- name: "Upload Combined Coverage to Coveralls"
127+
if: ${{ steps.show.outcome != 'failure' }}
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
run: |
131+
coveralls --service=github
72132
73133
Deploy:
74134
needs: tests

.github/workflows/python_ci_macos.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,11 @@ jobs:
6666
- name: "Run Tests for Python ${{ matrix.config.python-version }}"
6767
if: steps.setup-python.outcome == 'success'
6868
run: python -m tox -e "${{ matrix.config.testenvs }}" -s false
69+
70+
- name: "Upload Coverage 🚀"
71+
uses: actions/upload-artifact@v4
72+
if: ${{ always() && steps.setup-python.outcome == 'success' }}
73+
with:
74+
name: "coverage-${{ matrix.config.python-version }}"
75+
path: .coverage
76+
include-hidden-files: true

README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ formate-trailing-commas
1616
:widths: 10 90
1717

1818
* - Tests
19-
- |actions_linux| |actions_windows| |actions_macos|
19+
- |actions_linux| |actions_windows| |actions_macos| |coveralls|
2020
* - PyPI
2121
- |pypi-version| |supported-versions| |supported-implementations| |wheel|
2222
* - Activity
@@ -50,6 +50,10 @@ formate-trailing-commas
5050
:target: https://dependency-dash.repo-helper.uk/github/python-formate/formate-trailing-commas/
5151
:alt: Requirements Status
5252

53+
.. |coveralls| image:: https://img.shields.io/coveralls/github/python-formate/formate-trailing-commas/master?logo=coveralls
54+
:target: https://coveralls.io/github/python-formate/formate-trailing-commas?branch=master
55+
:alt: Coverage
56+
5357
.. |codefactor| image:: https://img.shields.io/codefactor/grade/github/python-formate/formate-trailing-commas?logo=codefactor
5458
:target: https://www.codefactor.io/repository/github/python-formate/formate-trailing-commas
5559
:alt: CodeFactor Grade

formate_trailing_commas/_vendor/add_trailing_comma/_ast_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def ast_to_offset(node: ast.AST) -> Offset:
1818
candidate = candidates.pop()
1919
if hasattr(candidate, 'lineno'):
2020
return Offset(candidate.lineno, candidate.col_offset)
21-
elif hasattr(candidate, '_fields'): # pragma: <3.9 cover
21+
elif hasattr(candidate, '_fields'): # pragma: no cover (py39+)
2222
for field in reversed(candidate._fields):
2323
candidates.append(getattr(candidate, field))
2424
else:

formate_trailing_commas/_vendor/add_trailing_comma/_plugins/_with.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from formate_trailing_commas._vendor.add_trailing_comma._token_helpers import fix_brace
1616

1717

18-
if sys.version_info >= (3, 9): # pragma: >=3.9 cover
18+
if sys.version_info >= (3, 9): # pragma: no cover (<py39)
1919
def _fix_with(i: int, tokens: list[Token]) -> None:
2020
i += 1
2121
if tokens[i].name == 'UNIMPORTANT_WS':

formate_trailing_commas/_vendor/add_trailing_comma/_plugins/literals.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _fix_tuple_py38(
9292
tokens: list[Token],
9393
*,
9494
one_el_tuple: bool,
95-
) -> None: # pragma: >=3.8 cover
95+
) -> None: # pragma: no cover (<py38)
9696
fix = find_simple(i, tokens)
9797

9898
# for tuples we *must* find a comma, otherwise it is not a tuple
@@ -121,6 +121,6 @@ def visit_Tuple(
121121
):
122122
func = functools.partial(_fix_tuple, one_el_tuple=is_one_el)
123123
yield ast_to_offset(node), func
124-
else: # pragma: >=3.8 cover
124+
else: # pragma: no cover (<py38)
125125
func = functools.partial(_fix_tuple_py38, one_el_tuple=is_one_el)
126126
yield ast_to_offset(node), func

formate_trailing_commas/_vendor/add_trailing_comma/_plugins/match.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from formate_trailing_commas._vendor.add_trailing_comma._token_helpers import fix_brace
1818

1919

20-
if sys.version_info >= (3, 10): # pragma: >=3.10 cover
20+
if sys.version_info >= (3, 10): # pragma: no cover (<py310)
2121
def _fix_match_class(
2222
i: int,
2323
tokens: list[Token],

repo_helper.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ license: 'MIT'
1111
short_desc: 'Formate plugin to add trailing commas.'
1212

1313
enable_conda: false
14-
enable_tests: false
1514
enable_docs: false
16-
min_coverage: 97
15+
min_coverage: 89
1716
use_whey: true
1817

1918
python_versions:

tests/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
coincidence>=0.2.0
2+
coverage>=5.1
3+
coverage-pyver-pragma>=0.2.1
4+
pytest>=6.0.0
5+
pytest-cov>=2.8.1
6+
pytest-randomly>=3.7.0
7+
pytest-timeout>=1.4.2

0 commit comments

Comments
 (0)