-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #250 from gerlero/pytest
Use pytest for testing
- Loading branch information
Showing
10 changed files
with
107 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/build | ||
Brewfile.lock.json | ||
*.tgz | ||
.DS_Store | ||
.DS_Store | ||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest>=7,<7.3 | ||
pytest-asyncio-cooperative>=0.36,<0.37 | ||
aiofoam>=0.4,<0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import pytest | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
from aiofoam import Case | ||
|
||
@pytest.fixture | ||
async def pitz_case(tmp_path): | ||
case = Case(Path(os.environ["FOAM_TUTORIALS"]) / "incompressible" / "simpleFoam" / "pitzDaily") | ||
return await case.clone(tmp_path / case.name) | ||
|
||
@pytest.mark.asyncio_cooperative | ||
async def test_pitz(pitz_case): | ||
await pitz_case.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
from aiofoam import Case | ||
|
||
@pytest.fixture | ||
async def blob(tmp_path): | ||
case = Case(Path(os.environ["FOAM_TUTORIALS"]) / "mesh" / "foamyHexMesh" / "blob") | ||
return await case.clone(tmp_path / case.name) | ||
|
||
@pytest.mark.parametrize("parallel", [False, True]) | ||
@pytest.mark.asyncio_cooperative | ||
async def test_blob(blob, parallel): | ||
await blob.run(parallel=parallel) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import pytest | ||
|
||
import os | ||
import shutil | ||
from pathlib import Path | ||
|
||
from aiofoam import Case | ||
|
||
@pytest.fixture | ||
async def flange(tmp_path): | ||
case = Case(Path(os.environ["FOAM_TUTORIALS"]) / "basic" / "laplacianFoam" / "flange") | ||
return await case.clone(tmp_path / case.name) | ||
|
||
@pytest.mark.asyncio_cooperative | ||
async def test_serial(flange): | ||
await flange.run(parallel=False) | ||
|
||
@pytest.mark.asyncio_cooperative | ||
async def test_parallel(flange): | ||
await flange.run(parallel=True) | ||
await flange.cmd(["reconstructPar"]) | ||
|
||
@pytest.mark.asyncio_cooperative | ||
async def test_parallel_manual(flange): | ||
shutil.copytree(flange.path / "0.orig", flange.path / "0") | ||
await flange.cmd(["ansysToFoam", Path(os.environ["FOAM_TUTORIALS"]) / "resources" / "geometry" / "flange.ans", "-scale", "0.001"]) | ||
await flange.run(script=False, parallel=True) | ||
await flange.cmd(["reconstructPar"]) | ||
|
||
@pytest.mark.asyncio_cooperative | ||
async def test_parallel_manual_shell(flange): | ||
shutil.copytree(flange.path / "0.orig", flange.path / "0") | ||
await flange.cmd("ansysToFoam \"$FOAM_TUTORIALS/resources/geometry/flange.ans\" -scale 0.001") | ||
await flange.cmd("decomposePar") | ||
await flange.cmd("laplacianFoam", parallel=True) | ||
await flange.cmd("reconstructPar") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
import os | ||
import subprocess | ||
from pathlib import Path | ||
|
||
from aiofoam import Case | ||
|
||
@pytest.fixture | ||
async def step(tmp_path): | ||
case = Case(Path(os.environ["FOAM_TUTORIALS"]) / "incompressible" / "simpleFoam" / "backwardFacingStep2D") | ||
return await case.clone(tmp_path / case.name) | ||
|
||
@pytest.mark.asyncio_cooperative | ||
async def test_step(step): | ||
await step.run() | ||
assert "FOAM Warning" not in (step.path / "log.simpleFoam").read_text() | ||
|
||
def test_cartesian(): # https://github.com/gerlero/openfoam-app/issues/88 | ||
subprocess.run(["cartesianMesh", "-help"], check=True) |