Skip to content

Commit

Permalink
Nose to pytest (#1239)
Browse files Browse the repository at this point in the history
* lint: updating code style with `make black`

* adding pytest related package

with

```
pipenv install --dev pytest
pipenv install --dev pytest-cov
```

* wsgi: fixing DeprecationWarning

when running tests there was this warning:

```
DeprecationWarning: 'werkzeug.urls.url_unquote' is deprecated and will be
removed in Werkzeug 2.4. Use 'urllib.parse.unquote' instead.
```

* tests: using `redirect_stdout` to redirect stdout to a readable source

* tests_utilities: fixing deprecation warning

```
DeprecationWarning: Please use assertRegex instead of assertRegexpMatches
```

* tests_utilities: removing try/finally in test_certify_sanity_checks

* tests_placebo: : fixing deprecation warning

```
DeprecationWarning: Please use assertRaisesRegex instead of assertRaisesRegexp
```

* zappa(core): fixing deprecation warning

```
DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
```

* tests_docs: fixing deprecation warning

```
DeprecationWarning: Please use assertEqual instead of assertEquals
```

* tests: moving from nose to pytest

keeping coverage results (aggregated) and duration display

* tests: removing and uninstalling all nose references
  • Loading branch information
dennybiasiolli authored May 4, 2023
1 parent 055db2e commit 7a5e153
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 151 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ htmlcov/
.coveragerc
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
Expand Down
33 changes: 24 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ clean:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
rm -rf .mypy_cache dist build *.egg-info
rm -f .coverage
coverage erase

requirements:
pip install pipenv>2021.11.15
Expand Down Expand Up @@ -56,24 +56,39 @@ flake:
flake8 zappa --count --exit-zero --max-complexity=55 --max-line-length=127 --statistics --ignore F403,F405,E203,E231,E252,W503

test-docs:
nosetests tests/tests_docs.py --with-coverage --cover-package=zappa --with-timer
pytest tests/tests_docs.py --cov=zappa --durations=0

test-handler:
nosetests tests/test_handler.py --with-coverage --cover-package=zappa --with-timer
pytest tests/test_handler.py --cov=zappa --durations=0

test-middleware:
nosetests tests/tests_middleware.py --with-coverage --cover-package=zappa --with-timer
pytest tests/tests_middleware.py --cov=zappa --durations=0

test-placebo:
nosetests tests/tests_placebo.py --with-coverage --cover-package=zappa --with-timer
pytest tests/tests_placebo.py --cov=zappa --durations=0

test-async:
nosetests tests/tests_async.py --with-coverage --cover-package=zappa --with-timer
pytest tests/tests_async.py --cov=zappa --durations=0

test-general:
nosetests tests/tests.py --with-coverage --cover-package=zappa --with-timer
pytest tests/tests.py --cov=zappa --durations=0

test-utilities:
nosetests tests/tests_utilities.py --with-coverage --cover-package=zappa --with-timer
pytest tests/tests_utilities.py --cov=zappa --durations=0

coverage-report:
coverage report --include="*/zappa*"

tests:
make clean
pytest \
tests/tests_docs.py \
tests/test_handler.py \
tests/tests_middleware.py \
tests/tests_placebo.py \
tests/tests_async.py \
tests/tests.py \
tests/tests_utilities.py \
--cov=zappa
--durations=0

tests: clean test-docs test-handler test-middleware test-placebo test-async test-general test-utilities
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Flask = "*"
isort = "*"
mock = "*"
mypy = "*"
nose = "*"
nose-timer = "*"
pipenv = ">2021.11.15"
packaging = "*"
pytest = "*"
pytest-cov = "*"

[packages]
argcomplete = "*"
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
install_requires=required,
python_requires=">=3.7",
tests_require=test_required,
test_suite="nose.collector",
include_package_data=True,
license="MIT License",
description="Server-less Python Web Services for AWS Lambda and API Gateway",
Expand Down
4 changes: 2 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /bin/bash
nosetests --with-coverage --cover-package=zappa
pytest --cov=zappa

# For a specific test:
# nosetests tests.tests:TestZappa.test_lets_encrypt_sanity -s
# pytest tests/tests.py::TestZappa::test_lets_encrypt_sanity
Loading

0 comments on commit 7a5e153

Please sign in to comment.