-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tests workflow * Add code coverage * Add examples * Update readme * Add num_context_lines to some funcs * Add some tests
- Loading branch information
1 parent
0be1995
commit fa030be
Showing
20 changed files
with
286 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Tests | ||
on: | ||
pull_request: | ||
branches: | ||
- 'master' | ||
push: | ||
branches: | ||
- 'master' | ||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.8, 3.9] | ||
steps: | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest-cov | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Lint with flake8 | ||
run: | | ||
flake8 traceback_with_variables --count --show-source --statistics --max-line-length=127 | ||
- name: Test with pytest | ||
run: | | ||
python -m pytest --cov=./traceback_with_variables --cov-report=xml | ||
- name: Upload Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from traceback_with_variables import override_print_tb | ||
|
||
|
||
def main(): | ||
override_print_tb() | ||
|
||
n = 0 | ||
print(1 / n) | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from traceback_with_variables import override_print_tb | ||
|
||
|
||
def main(): | ||
override_print_tb( | ||
num_context_lines=3, | ||
max_value_str_len=100, | ||
max_exc_str_len=1000, | ||
ellipsis_='...', | ||
activate_by_env_var='PY_PRINT_VARS', | ||
deactivate_by_env_var='PY_DONT_PRINT_VARS' | ||
) | ||
|
||
n = 0 | ||
print(1 / n) | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import logging | ||
|
||
from traceback_with_variables import printing_tb, LoggerAsFile | ||
|
||
|
||
logging.basicConfig(format='%(asctime)-15s %(name)s %(levelname)s %(message)s') | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def f(n): | ||
print(1 / n) | ||
|
||
|
||
def main(): | ||
with printing_tb(file_=LoggerAsFile(logger)): | ||
x = 1 | ||
f(x - 1) | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import logging | ||
|
||
from traceback_with_variables import prints_tb, LoggerAsFile | ||
|
||
|
||
logging.basicConfig(format='%(asctime)-15s %(name)s %(levelname)s %(message)s') | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@prints_tb(file_=LoggerAsFile(logger)) | ||
def f(n): | ||
print(1 / n) | ||
|
||
|
||
def main(): | ||
f(0) | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from traceback_with_variables import printing_tb | ||
|
||
|
||
def f(n): | ||
print(1 / n) | ||
|
||
|
||
def main(): | ||
with printing_tb(): | ||
x = 1 | ||
f(x - 1) | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from traceback_with_variables import printing_tb | ||
|
||
|
||
def f(n): | ||
print(1 / n) | ||
|
||
|
||
def main(): | ||
with printing_tb( | ||
num_context_lines=3, | ||
max_value_str_len=100, | ||
max_exc_str_len=1000, | ||
ellipsis_='...', | ||
skip_cur_frame=True, # e.g. no info about 'x' | ||
reraise=False, # i.e. program won't fail, exceptions stay inside | ||
): | ||
x = 1 | ||
f(x - 1) | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from traceback_with_variables import prints_tb | ||
|
||
|
||
@prints_tb | ||
def f(n): | ||
print(1 / n) | ||
|
||
|
||
def main(): | ||
f(0) | ||
|
||
|
||
main() |
Oops, something went wrong.