Skip to content

Commit 8777f84

Browse files
committed
Initial versions
0 parents  commit 8777f84

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

.github/workflows/tox.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Python package
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ['3.10', '3.11', '3.12.0']
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Set up Python ${{ matrix.python-version }}
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
python -m pip install tox tox-gh-actions
24+
- name: Test with tox
25+
run: tox

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.coverage

example.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import asyncio
2+
import coverage
3+
4+
5+
async def run():
6+
def raise_exception():
7+
raise RuntimeError("This is a test exception.")
8+
9+
async def return_false():
10+
# simply returning false here causes the incorrectly missed line to be marked as hit
11+
try:
12+
await asyncio.to_thread(raise_exception)
13+
# raise RuntimeError("This is a test exception.") # doing this instead will cause line below to show up
14+
finally:
15+
return False
16+
17+
# remove this conditional also fixes the problem
18+
if await return_false():
19+
return False
20+
21+
await asyncio.to_thread(print, "hello",) # this line is incorrectly marked as missing the coverage report
22+
23+
24+
if __name__ == '__main__':
25+
cov = coverage.Coverage(branch=False)
26+
cov.start()
27+
28+
asyncio.run(run())
29+
30+
cov.stop()
31+
cov.save()
32+
33+
cov.report(show_missing=True)

tox.ini

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[tox]
2+
requires =
3+
tox>=4
4+
tox-gh-actions
5+
6+
env_list = py{310,311,312_0}
7+
8+
[gh-actions]
9+
python =
10+
3.10: py310
11+
3.11: py312
12+
3.12.0: py312_0
13+
14+
[testenv:py312_0]
15+
basepython = python3.12.0
16+
17+
[testenv]
18+
description = run unit tests
19+
deps =
20+
coverage
21+
commands =
22+
python --version
23+
python example.py

0 commit comments

Comments
 (0)