Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pygwinc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
gwinc
pygwinc
Commits
504b9e8e
Commit
504b9e8e
authored
2 years ago
by
Kevin Kuns
Browse files
Options
Downloads
Patches
Plain Diff
add a pytest marker to specify tests that generate test data
parent
c606f75b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!151
Pytest enhancements
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
conftest.py
+29
-0
29 additions, 0 deletions
conftest.py
pytest.ini
+1
-0
1 addition, 0 deletions
pytest.ini
with
32 additions
and
1 deletion
.gitignore
+
2
−
1
View file @
504b9e8e
#for docs and setup.py outputs
build/
tresults/
tresults
*
/
# test cache
gwinc/test/cache
test/*/*.h5
# Byte-compiled / optimized / DLL files
__pycache__/
...
...
This diff is collapsed.
Click to expand it.
conftest.py
+
29
−
0
View file @
504b9e8e
...
...
@@ -40,6 +40,14 @@ def pytest_addoption(parser):
help
=
"
Do not preclear tpaths
"
,
)
parser
.
addoption
(
"
--generate
"
,
action
=
"
store_true
"
,
default
=
False
,
dest
=
"
generate
"
,
help
=
"
Generate test data
"
,
)
@pytest.fixture
def
plot
(
request
):
...
...
@@ -270,3 +278,24 @@ def relfile_test(_file_, request, pre = None, post = None, fname = None):
else
:
return
relfile
(
_file_
,
testname
,
fname
=
fname
)
def
pytest_collection_modifyitems
(
config
,
items
):
"""
Modifies tests to be selectively skipped with command line options
https://docs.pytest.org/en/latest/example/simple.html#control-skipping-of-tests-according-to-command-line-option
"""
# run tests marked as generate if and only if --generate is given
# skip all others in this case
if
config
.
getoption
(
'
--generate
'
):
skip
=
pytest
.
mark
.
skip
(
reason
=
'
only running tests that generate data
'
)
for
item
in
items
:
if
'
generate
'
not
in
item
.
keywords
:
item
.
add_marker
(
skip
)
else
:
skip
=
pytest
.
mark
.
skip
(
reason
=
'
generates test data: needs --generate to run
'
)
for
item
in
items
:
if
'
generate
'
in
item
.
keywords
:
item
.
add_marker
(
skip
)
This diff is collapsed.
Click to expand it.
pytest.ini
+
1
−
0
View file @
504b9e8e
...
...
@@ -9,6 +9,7 @@ markers =
fast:
marks
tests
as
being
fast,
usually
it
does
not
make
plots
logic:
is
a
test
of
the
code
logic
noise:
is
a
test
of
the
noise
curves
generate:
marks
a
function
that
generates
test
data
[pytest-watch]
ignore
=
.*
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment