Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Chaofan Chen
ogs
Commits
43d95588
Verified
Commit
43d95588
authored
1 year ago
by
Lars Bilke
Browse files
Options
Downloads
Patches
Plain Diff
[py] ruff fixes in Tests/Python/test_ogs_asm_threads.py.
parent
b02069e7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Tests/Python/test_ogs_asm_threads.py
+17
-20
17 additions, 20 deletions
Tests/Python/test_ogs_asm_threads.py
with
17 additions
and
20 deletions
Tests/Python/test_ogs_asm_threads.py
+
17
−
20
View file @
43d95588
import
os
import
platform
import
tempfile
from
pathlib
import
Path
import
ogs.simulator
as
sim
import
pytest
...
...
@@ -30,9 +30,7 @@ def run(prjpath, outdir, expect_successful):
def
check_simulation_results_exist
(
outdir
):
assert
os
.
path
.
exists
(
os
.
path
.
join
(
outdir
,
"
anisotropic_thermal_expansion_ts_1_t_1000000.000000.vtu
"
)
)
assert
(
outdir
/
"
anisotropic_thermal_expansion_ts_1_t_1000000.000000.vtu
"
).
exists
()
@pytest.mark.parametrize
(
...
...
@@ -59,11 +57,11 @@ def check_simulation_results_exist(outdir):
],
)
def
test_ogs_asm_threads_env_var
(
monkeypatch
,
asm_threads_parameter
):
srcdir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"
..
"
,
"
..
"
)
prjpath
=
os
.
path
.
join
(
srcdir
,
# fast running model with TRM process (OpenMP parallelized)
"
Tests/Data/ThermoRichardsMechanics/anisotropic_thermal_expansion/aniso_expansion.prj
"
,
srcdir
=
Path
(
__file__
).
parent
.
parent
.
parent
# fast running model with TRM process (OpenMP parallelized)
prjpath
=
(
srcdir
/
"
Tests/Data/ThermoRichardsMechanics/anisotropic_thermal_expansion/aniso_expansion.prj
"
)
asm_threads_setting
,
expect_ogs_success
=
asm_threads_parameter
...
...
@@ -72,17 +70,16 @@ def test_ogs_asm_threads_env_var(monkeypatch, asm_threads_parameter):
# Empty env var not supported on Windows!
return
with
tempfile
.
TemporaryDirectory
()
as
tmpdirname
:
# https://docs.pytest.org/en/6.2.x/reference.html#pytest.MonkeyPatch
with
monkeypatch
.
context
()
as
ctx
:
# prepare environment
if
asm_threads_setting
is
not
False
:
ctx
.
setenv
(
"
OGS_ASM_THREADS
"
,
asm_threads_setting
)
# https://docs.pytest.org/en/6.2.x/reference.html#pytest.MonkeyPatch
with
tempfile
.
TemporaryDirectory
()
as
tmpdirname
,
monkeypatch
.
context
()
as
ctx
:
# prepare environment
if
asm_threads_setting
is
not
False
:
ctx
.
setenv
(
"
OGS_ASM_THREADS
"
,
asm_threads_setting
)
ctx
.
chdir
(
tmpdirname
)
ctx
.
chdir
(
tmpdirname
)
# run and test
run
(
prjpath
,
tmpdirname
,
expect_ogs_success
)
# run and test
run
(
prjpath
,
Path
(
tmpdirname
)
,
expect_ogs_success
)
if
expect_ogs_success
:
check_simulation_results_exist
(
tmpdirname
)
if
expect_ogs_success
:
check_simulation_results_exist
(
Path
(
tmpdirname
)
)
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