Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tox to run the full test suite #344

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[run]
branch = true
parallel = true
data_file = .tox/.coverage-data-files/.coverage
source =
flask_cors
tests


[paths]
source =
src
*/site-packages


[report]
fail_under = 84
26 changes: 14 additions & 12 deletions .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11"]
dependencies:
- "flask==1.1 Jinja2==3.0.3 itsdangerous==2.0.1 werkzeug==2.0.3"
- "flask==2.3.2"
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
# You can test your matrix by printing the current Python version
- name: Install deps
run: pip install -U setuptools pep8 coverage docutils pygments packaging pytest pytest-cov ${{ matrix.dependencies }}
- name: Setup a virtual environment
run: |
python -m venv .venv
.venv/bin/python -m pip install --upgrade pip setuptools wheel
.venv/bin/python -m pip install tox
- name: Run tests
run: |
coverage erase
python setup.py clean build install
pytest --cov=flask_cors
.venv/bin/tox run -m py${{ matrix.python-version}}
7 changes: 2 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,8 @@ If things aren't working as you expect, enable logging to help understand what i
Tests
-----

A simple set of tests is included in ``test/``.
To run, install nose, and simply invoke ``nosetests`` or ``python setup.py test`` to exercise the tests.

If nosetests does not work for you, due to it no longer working with newer python versions.
You can use pytest to run the tests instead.
To exercise the full test suite across all available and supported Python and Flask versions,
install tox, and run ``tox run`` or ``tox run-parallel``.

Contributing
------------
Expand Down
9 changes: 9 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[pytest]
addopts = --color=yes
filterwarnings =
error
# Ignore ancient Flask 1-related deprecation warnings
ignore:Importing 'itsdangerous.json' is deprecated
ignore:ast.Str is deprecated
ignore:Attribute s is deprecated
ignore:'BaseResponse' is deprecated
18 changes: 18 additions & 0 deletions requirements/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
requirements files
##################

The subdirectories in ``requirements/`` contain ``pyproject.toml`` files
with minimal Poetry configurations to define tool requirements for testing.

To update the exported ``requirements.txt`` files in the subdirectories,
run the included tox label, ``update``.

.. code-block::

tox run -m update


If the flask-cors Python support changes,
update the Python requirements in the ``pyproject.toml`` files.
For example, when Python 3.8 support is dropped,
change ``">=3.8"`` to ``">=3.9"`` and run the tox ``update`` label.
228 changes: 228 additions & 0 deletions requirements/test/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions requirements/test/poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[warnings]
export = false
16 changes: 16 additions & 0 deletions requirements/test/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "test requirements"
version = "0"
description = ""
authors = []

[tool.poetry.dependencies]
python = ">=3.8"
coverage = {extras = ["toml"], version = "*"}
pytest = "*"
pytest-randomly = "*"
pyfakefs = "*"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
12 changes: 12 additions & 0 deletions requirements/test/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
colorama==0.4.6 ; python_version >= "3.8" and sys_platform == "win32"
coverage[toml]==7.4.4 ; python_version >= "3.8"
exceptiongroup==1.2.0 ; python_version < "3.11" and python_version >= "3.8"
importlib-metadata==7.1.0 ; python_version < "3.10" and python_version >= "3.8"
iniconfig==2.0.0 ; python_version >= "3.8"
packaging==24.0 ; python_version >= "3.8"
pluggy==1.4.0 ; python_version >= "3.8"
pyfakefs==5.3.5 ; python_version >= "3.8"
pytest-randomly==3.15.0 ; python_version >= "3.8"
pytest==8.1.1 ; python_version >= "3.8"
tomli==2.0.1 ; python_full_version <= "3.11.0a6" and python_version >= "3.8"
zipp==3.18.1 ; python_version < "3.10" and python_version >= "3.8"
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
Expand Down
Loading