Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
pyMOR
pymor
Commits
851a26ba
Commit
851a26ba
authored
Oct 10, 2022
by
René Fritze
Browse files
[tests] turn missing records for check_results into an exception
This allows to exercise the code in a test function
parent
6532dbfe
Changes
4
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
851a26ba
...
...
@@ -74,3 +74,4 @@ Pipfile.lock
.hypothesis
.vscode
.ci/create_conda_env.log
src/pymortests/testdata/check_results/test_check_check_results_miss*
src/pymor/core/exceptions.py
View file @
851a26ba
...
...
@@ -105,3 +105,9 @@ class UnpicklableError(Exception):
def
__str__
(
self
):
return
f
'
{
self
.
cls
}
cannot be pickled.'
class
NoResultDataError
(
Exception
):
def
__init__
(
self
,
msg
=
None
):
msg
=
msg
or
'missing testdata, re-run test'
super
().
__init__
(
msg
)
src/pymortests/base.py
View file @
851a26ba
...
...
@@ -16,7 +16,7 @@ from pytest import skip
from
pymor.algorithms.basic
import
almost_equal
,
relative_error
from
pymor.core
import
config
from
pymor.core.exceptions
import
DependencyMissingError
from
pymor.core.exceptions
import
DependencyMissingError
,
NoResultDataError
def
runmodule
(
filename
):
...
...
@@ -61,8 +61,8 @@ def check_results(test_name, params, results, *args):
if
not
os
.
path
.
exists
(
testname_dir
):
os
.
mkdir
(
testname_dir
)
_dump_results
(
filename
,
results
)
assert
False
,
\
f
'No results found for test
{
test_name
}
(
{
params
}
), saved current results.
Remember to check in
{
filename
}
.'
raise
NoResultDataError
(
msg
=
f
'No results found for test
{
test_name
}
(
{
params
}
), saved current results.'
f
'
Remember to check in
{
filename
}
.'
)
for
k
,
(
atol
,
rtol
)
in
keys
.
items
():
if
not
np
.
all
(
np
.
allclose
(
old_results
[
k
],
results
[
k
],
atol
=
atol
,
rtol
=
rtol
)):
...
...
src/pymortests/demos.py
View file @
851a26ba
# This file is part of the pyMOR project (https://www.pymor.org).
# Copyright pyMOR developers and contributors. All rights reserved.
# License: BSD 2-Clause License (https://opensource.org/licenses/BSD-2-Clause)
import
math
import
os
import
shutil
from
importlib
import
import_module
...
...
@@ -13,7 +13,13 @@ from typer.testing import CliRunner
import
pymordemos
# noqa: F401
from
pymor.core.config
import
is_macos_platform
,
is_windows_platform
from
pymor.core.exceptions
import
GmshMissingError
,
MeshioMissingError
,
QtMissingError
,
TorchMissingError
from
pymor.core.exceptions
import
(
GmshMissingError
,
MeshioMissingError
,
NoResultDataError
,
QtMissingError
,
TorchMissingError
,
)
from
pymor.tools.mpi
import
parallel
from
pymortests.base
import
check_results
,
runmodule
...
...
@@ -367,5 +373,18 @@ def test_parabolic_mor_results():
'min_effectivities'
,
'max_effectivities'
,
'errors'
)
def
test_check_check_results_missing
(
tmp_path
):
test_name
=
tmp_path
.
name
args
=
[
'NONE'
,
tmp_path
]
results
=
{
"error"
:
math
.
pi
}
with
pytest
.
raises
(
NoResultDataError
):
check_results
(
test_name
,
args
,
results
,
"error"
)
# running same check again against now recored data must be fine
check_results
(
test_name
,
args
,
results
,
"error"
)
with
pytest
.
raises
(
AssertionError
):
results
[
"error"
]
+=
1
check_results
(
test_name
,
args
,
results
,
"error"
)
if
__name__
==
'__main__'
:
runmodule
(
filename
=
__file__
)
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