From 8a82454e75227bd658016a662045260d183503f6 Mon Sep 17 00:00:00 2001 From: Evgeniy Blinov Date: Tue, 10 Oct 2023 00:54:09 +0300 Subject: [PATCH] tests --- .github/workflows/coverage.yml | 41 +++++++++++++++++++ .gitignore | 1 + tests/units/__init__.py | 0 tests/units/decorators/__init__.py | 0 .../test_tail_recursion_optimization.py | 13 ++++++ 5 files changed, 55 insertions(+) create mode 100644 .github/workflows/coverage.yml create mode 100644 tests/units/__init__.py create mode 100644 tests/units/decorators/__init__.py create mode 100644 tests/units/decorators/test_tail_recursion_optimization.py diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..0693855 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,41 @@ +name: Tests + +on: + push + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install the library + shell: bash + run: python setup.py install + + - name: Install dependencies + shell: bash + run: pip install -r requirements_dev.txt + + - name: Run tests and show coverage on the command line + run: coverage run --source=astrologic --omit="*tests*" -m pytest --cache-clear && coverage report -m + + - name: Upload reports to codecov + env: + CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} + if: runner.os == 'Linux' + run: | + curl -Os https://uploader.codecov.io/latest/linux/codecov + find . -iregex "codecov.*" + chmod +x codecov + ./codecov -t ${CODECOV_TOKEN} diff --git a/.gitignore b/.gitignore index a987409..09f5942 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build .DS_Store venv test.py +.pytest_cache diff --git a/tests/units/__init__.py b/tests/units/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/units/decorators/__init__.py b/tests/units/decorators/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/units/decorators/test_tail_recursion_optimization.py b/tests/units/decorators/test_tail_recursion_optimization.py new file mode 100644 index 0000000..f3f207a --- /dev/null +++ b/tests/units/decorators/test_tail_recursion_optimization.py @@ -0,0 +1,13 @@ +import sys + +from astrologic import no_recursion + + +def test_big_recursion(): + @no_recursion + def c(b): + if b == sys.getrecursionlimit() * 10: + return b + return c(b + 1) + + assert c(0) == sys.getrecursionlimit() * 10