diff --git a/.circleci/config.yml b/.circleci/config.yml index 8805698..aff75e9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,15 +13,20 @@ jobs: - run: name: Install packages command: apk add postgresql-libs gcc musl-dev postgresql-dev git + - run: name: Install Python packages command: pip install -r requirements/test.txt + - run: name: Run tests command: tox -e 'py37-dj{20,21,22}' environment: DATABASE_URL: 'postgres://localizedfields:localizedfields@localhost:5432/localizedfields' + - store_test_results: + path: reports + lint: docker: - image: python:3.7-alpine @@ -30,12 +35,14 @@ jobs: - run: name: Install packages command: apk add postgresql-libs gcc musl-dev postgresql-dev git + - run: name: Install Python packages command: pip install -r requirements/test.txt + - run: - name: Lint code - command: python setup.py lint + name: Verify formatting / linting + command: python setup.py verify workflows: diff --git a/.gitignore b/.gitignore index 0b8aef4..835952e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Ignore virtual environments env/ .env/ +venv/ # Ignore Python byte code cache *.pyc @@ -9,7 +10,7 @@ __pycache__ # Ignore coverage reports .coverage -htmlcov +reports/ # Ignore build results *.egg-info/ diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..befe129 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +DJANGO_SETTINGS_MODULE=settings +testpaths=tests +addopts=-m "not benchmark" diff --git a/requirements/test.txt b/requirements/test.txt index fcbce7e..bcccac9 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -16,7 +16,7 @@ pytest==5.2.1 pytest-django==3.6.0 pytest-cov==2.8.1 +# Test support django-autoslug==1.9.3 django-bleach==0.3.0 psycopg2==2.7.3.2 -coverage==4.4.2 diff --git a/setup.py b/setup.py index ff95946..e25deea 100644 --- a/setup.py +++ b/setup.py @@ -138,5 +138,19 @@ setup( ] ], ), + "test": create_command( + "Runs all the tests", + [ + [ + "pytest", + "--cov=localized_fields", + "--cov-report=term", + "--cov-report=xml:reports/xml", + "--cov-report=html:reports/html", + "--junitxml=reports/junit/tests.xml", + "--reuse-db", + ] + ], + ), }, ) diff --git a/tox.ini b/tox.ini index b267cd4..2d5450e 100644 --- a/tox.ini +++ b/tox.ini @@ -10,4 +10,4 @@ deps = setenv = DJANGO_SETTINGS_MODULE=settings passenv = DATABASE_URL -commands = coverage run manage.py test +commands = python setup.py test