Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
geomultisens
specclassify
Commits
e6e54734
Commit
e6e54734
authored
Dec 16, 2021
by
Daniel Scheffler
Browse files
Merge branch 'enhancement/migrate_to_pytest' into 'master'
Enhancement/migrate to pytest See merge request
!6
parents
f6b00607
d619c19c
Pipeline
#36280
passed with stages
in 15 minutes and 23 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.coveragerc
0 → 100644
View file @
e6e54734
# .coveragerc to control coverage.py
[run]
branch = False
concurrency = multiprocessing
parallel = True
omit = */site-packages/*,*/tests/*,*/.eggs/*
[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
.gitlab-ci.yml
View file @
e6e54734
...
...
@@ -11,16 +11,25 @@ test_specclassify:
stage
:
test
script
:
-
source /root/mambaforge/bin/activate ci_env
-
make nosetests
-
pip install pytest pytest-cov pytest-reporter-html1
# TODO remove after recreating CI runner
# run tests
-
make pytest
# create the docs
-
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
...
...
@@ -79,7 +88,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/
nose
test
s
_reports
-
mkdir -p public/test_reports
# Copy over the docs
-
cp -r docs/_build/html/* public/doc/
...
...
@@ -87,14 +96,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
nose
test
s
reports
-
cp
nosetests.*
public/
nose
test
s
_reports/
# Copy over the test reports
-
cp
report.html
public/test_reports/
# Check if everything is working great
-
ls -al public
-
ls -al public/doc
-
ls -al public/coverage
-
ls -al public/
nose
test
s
_reports
-
ls -al public/test_reports
artifacts
:
paths
:
-
public
...
...
Makefile
View file @
e6e54734
.PHONY
:
clean clean-test clean-pyc clean-build docs help
nose
test
s
.PHONY
:
clean clean-test clean-pyc clean-build docs help
py
test
.DEFAULT_GOAL
:=
help
define
BROWSER_PYSCRIPT
...
...
@@ -51,8 +51,10 @@ 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
rm
-fr
.pytest_cache
lint
:
##
check style with flake8
flake8
--max-line-length
=
120 specclassify tests
>
./tests/linting/flake8.log
||
\
...
...
@@ -78,12 +80,22 @@ coverage: ## check code coverage quickly with the default Python
coverage html
#
$(BROWSER)
htmlcov/index.html
nose
test
s
:
clean-test
##
Runs
nose
test
s
with coverage
,
xUnit and nose-html-outpu
t
py
test
:
clean-test
##
Runs
py
test with coverage
and creates coverage and test repor
t
## - 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
=
specclassify
--cover-package
=
bin
--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 pytest-cov
)
are defined
in
.pytest.ini and .coveragerc
pytest tests
\
--verbosity
=
3
\
--color
=
yes
\
--tb
=
short
\
--cov
=
specclassify
\
--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/specclassify.rst
...
...
setup.py
View file @
e6e54734
...
...
@@ -42,7 +42,7 @@ requirements = ['numpy', 'tqdm', 'matplotlib', 'scikit-learn', 'geoarray>=0.15.0
setup_requirements
=
[]
test_requirements
=
[
'
coverage'
,
'nose'
,
'nose2'
,
'nose-htmloutput'
,
'rednose
'
,
'dill'
,
'urlchecker'
]
test_requirements
=
[
'
pytest'
,
'pytest-cov'
,
'pytest-reporter-hmtl1
'
,
'dill'
,
'urlchecker'
]
setup
(
author
=
"Daniel Scheffler"
,
...
...
specclassify/_baseclasses.py
View file @
e6e54734
...
...
@@ -109,6 +109,8 @@ class _ImageClassifier(object):
if
self
.
CPUs
is
None
or
self
.
CPUs
>
1
:
with
Pool
(
self
.
CPUs
,
initializer
=
_mp_initializer
,
initargs
=
(
self
.
train_spectra
,
image_cube_gA
))
as
pool
:
tiles_results
=
list
(
pool
.
imap_unordered
(
self
.
_predict_tilewise
,
bounds_alltiles
))
pool
.
close
()
# needed to make coverage work in multiprocessing
pool
.
join
()
else
:
_mp_initializer
(
self
.
train_spectra
,
image_cube_gA
)
...
...
tests/CI_docker/context/environment_specclassify.yml
View file @
e6e54734
...
...
@@ -16,15 +16,13 @@ dependencies:
-
tqdm
# test and doc dependencies
-
coverage
-
flake8
-
nose
-
nose2
-
nose-htmloutput
-
pycodestyle
-
pylint
-
pydocstyle
-
rednose
-
pytest
-
pytest-cov
-
pytest-reporter-html1
-
sphinx-argparse
-
sphinx-autodoc-typehints
-
sphinx_rtd_theme
...
...
tests/test_image_classifier.py
View file @
e6e54734
...
...
@@ -417,3 +417,8 @@ class Test_RF_Classifier(unittest.TestCase):
RFC
=
RF_Classifier
(
cluster_centers
,
cluster_labels
,
CPUs
=
None
,
**
dict
(
random_state
=
0
))
cmap_mp
=
RFC
.
classify
(
test_gA_pure_endmembers
,
in_nodataVal
=-
9999
,
tiledims
=
(
400
,
200
))
self
.
assertTrue
(
np
.
array_equal
(
cmap_mp
.
flatten
(),
cluster_labels
))
if
__name__
==
'__main__'
:
import
pytest
pytest
.
main
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment