Commit e54536b3 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Merge branch 'enhancement/migrate_to_pytest' into 'master'

migrate test calls to pytest

See merge request !33
parents 16b208a9 ee1416a0
Pipeline #35165 failed with stages
in 10 minutes and 30 seconds
# .coveragerc to control coverage.py
[run]
branch = False
concurrency = multiprocessing
parallel = True
[report]
show_missing = True
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover
# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError
# Don't complain if non-runnable code isn't run:
if 0:
if __name__ == .__main__.:
ignore_errors = True
[html]
directory = htmlcov
......@@ -21,16 +21,22 @@ test_py_tools_ds:
script:
- source /root/mambaforge/bin/activate ci_env
- pip install -U nose --no-binary ':all:' # FIXME: fixes nose issue: https://github.com/nose-devs/nose/issues/1099
# TODO remove as soon as CI runner is rebuilt
- mamba install pandas
- pip install pytest pytest-cov pytest-reporter-html1
- make nosetests
- make pytest
- make docs
artifacts:
expose_as: 'Test and coverage report'
paths:
- htmlcov/
- report.html
- docs/_build/html/
- nosetests.html
- nosetests.xml
reports:
cobertura: coverage.xml
junit: report.xml
expire_in: 30 days
when: always
......@@ -89,7 +95,7 @@ pages: # this job must be called 'pages' to advise GitLab to upload content to
- mkdir public
- mkdir -p public/doc
- mkdir -p public/coverage
- mkdir -p public/nosetests_reports
- mkdir -p public/tests_reports
# Copy over the docs
- cp -r docs/_build/html/* public/doc/
......@@ -97,14 +103,14 @@ pages: # this job must be called 'pages' to advise GitLab to upload content to
# Copy over the coverage reports
- cp -r htmlcov/* public/coverage/
# Copy over the nosetests reports
- cp nosetests.* public/nosetests_reports/
# Copy over the tests reports
- cp report.html public/tests_reports/
# Check if everything is working great
- ls -al public
- ls -al public/doc
- ls -al public/coverage
- ls -al public/nosetests_reports
- ls -al public/tests_reports
artifacts:
paths:
- public
......
.PHONY: clean clean-test clean-pyc clean-build docs help nosetests
.PHONY: clean clean-test clean-pyc clean-build docs help pytest
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
......@@ -49,8 +49,9 @@ clean-test: ## remove test and coverage artifacts
rm -f .coverage
rm -fr .coverage.*
rm -fr htmlcov/
rm -fr nosetests.html
rm -fr nosetests.xml
rm -fr report.html
rm -fr report.xml
rm -fr coverage.xml
lint: ## check style with flake8
flake8 --max-line-length=120 py_tools_ds tests > ./tests/linting/flake8.log || \
......@@ -77,12 +78,22 @@ coverage: ## check code coverage quickly with the default Python
coverage html
#$(BROWSER) htmlcov/index.html
nosetests: clean-test ## Runs nosetests with coverage, xUnit and nose-html-output
pytest: clean-test ## Runs pytest with coverage and creates coverage and test report
## - puts the coverage results in the folder 'htmlcov'
## - generates 'nosetests.html' (--with-html)
## - generates 'nosetests.xml' (--with-xunit) which is currently not visualizable by GitLab
nosetests -vv --with-coverage --cover-package=py_tools_ds --cover-erase --cover-html --cover-html-dir=htmlcov \
--with-html --with-xunit --rednose --force-color
## - generates cobertura 'coverage.xml' (needed to show coverage in GitLab MR changes)
## - generates 'report.html' based on pytest-reporter-html1
## - generates JUnit 'report.xml' to show the test report as a new tab in a GitLab MR
## NOTE: additional options pytest and coverage (plugin pyteest-cov) are defined in .pytest.ini and .coveragerc
pytest tests \
--verbosity=3 \
--color=yes \
--tb=short \
--cov=py_tools_ds \
--cov-report html:htmlcov \
--cov-report term-missing \
--cov-report xml:coverage.xml \
--template=html1/index.html --report=report.html \
--junitxml report.xml
docs: ## generate Sphinx HTML documentation, including API docs
rm -f docs/py_tools_ds.rst
......
......@@ -28,7 +28,7 @@ Status
.. image:: https://img.shields.io/pypi/dm/py_tools_ds.svg
:target: https://pypi.python.org/pypi/py_tools_ds
See also the latest coverage_ report and the nosetests_ HTML report.
See also the latest coverage_ report and the pytest_ HTML report.
Features
......@@ -82,5 +82,5 @@ This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypack
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
.. _coverage: https://danschef.git-pages.gfz-potsdam.de/py_tools_ds/coverage/
.. _nosetests: https://danschef.git-pages.gfz-potsdam.de/py_tools_ds/nosetests_reports/nosetests.html
.. _pytest: https://danschef.git-pages.gfz-potsdam.de/py_tools_ds/tests_reports/report.html
.. _conda: https://conda.io/docs/
......@@ -24,7 +24,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import (division, print_function, absolute_import, unicode_literals)
from .version import __version__, __versionalias__ # noqa (E402 + F401)
__author__ = 'Daniel Scheffler'
......@@ -76,5 +76,7 @@ def gdal_ReadAsArray_mp(fPath, bandNr, tilesize=1500):
with multiprocessing.Pool() as pool:
pool.map(fill_arr, fill_arr_argDicts)
pool.close()
pool.join()
return shared_array
......@@ -136,3 +136,5 @@ def convert_gdal_to_bsq__mp(in_path, out_path, band=1):
with multiprocessing.Pool() as pool:
pool.map(fill_arr_on_disk, argDicts)
pool.close()
pool.join()
......@@ -48,8 +48,7 @@ requirements = [
'spectral'
]
setup_requirements = ['setuptools']
test_requirements = requirements + ["coverage", "gdal", "nose", "nose2", "nose-htmloutput", "rednose", "shapely",
"urlchecker"]
test_requirements = requirements + ["gdal", "pytest", "pytest-cov", "pytest-reporter-html1", "shapely", "urlchecker"]
setup(
name='py_tools_ds',
......
......@@ -9,20 +9,19 @@ dependencies:
- gdal>=2.1.0
- numpy
- pandas
- pyproj>=2.5.0
- shapely
- pip:
- spectral
- coverage
- flake8
- nose
- nose2
- nose-htmloutput
- pycodestyle
- pydocstyle
- pylint
- rednose
- pytest
- pytest-cov
- pytest-reporter-html1
- sphinx-argparse
- urlchecker
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# py_tools_ds - A collection of geospatial data analysis tools that simplify standard
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# py_tools_ds - A collection of geospatial data analysis tools that simplify standard
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# py_tools_ds - A collection of geospatial data analysis tools that simplify standard
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# py_tools_ds - A collection of geospatial data analysis tools that simplify standard
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# py_tools_ds - A collection of geospatial data analysis tools that simplify standard
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment