Skip to content

Commit e7df6b4

Browse files
committed
test: implement tests/* for parallel rom
1 parent 1361bd4 commit e7df6b4

20 files changed

Lines changed: 453 additions & 57 deletions

tests/test_parallel.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

tests/test_parallel/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import matplotlib
2+
3+
matplotlib.use("Agg")

tests/test_parallel/test_ae.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import pytest
3+
import sys
4+
from unittest import mock
5+
6+
# 1. Shield the imports
7+
try:
8+
from ezyrb.parallel import ReducedOrderModel as ParallelROM
9+
import tests.test_ae as original_module
10+
HAS_PARALLEL = True
11+
except ImportError:
12+
HAS_PARALLEL = False
13+
14+
if not HAS_PARALLEL:
15+
raise unittest.SkipTest("Parallel dependencies missing")
16+
17+
# 2. The "Lazy" Swap (Monkeypatching)
18+
# We replace the ROM in the original module's namespace
19+
# so that decorators like @pytest.mark.parametrize use the Parallel version.
20+
original_module.ROM = ParallelROM
21+
if hasattr(original_module, 'ReducedOrderModel'):
22+
original_module.ReducedOrderModel = ParallelROM
23+
24+
# 3. Re-export the tests so pytest finds them here
25+
from tests.test_ae import *

tests/test_parallel/test_ann.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import pytest
3+
import sys
4+
from unittest import mock
5+
6+
# 1. Shield the imports
7+
try:
8+
from ezyrb.parallel import ReducedOrderModel as ParallelROM
9+
import tests.test_ann as original_module
10+
HAS_PARALLEL = True
11+
except ImportError:
12+
HAS_PARALLEL = False
13+
14+
if not HAS_PARALLEL:
15+
raise unittest.SkipTest("Parallel dependencies missing")
16+
17+
# 2. The "Lazy" Swap (Monkeypatching)
18+
# We replace the ROM in the original module's namespace
19+
# so that decorators like @pytest.mark.parametrize use the Parallel version.
20+
original_module.ROM = ParallelROM
21+
if hasattr(original_module, 'ReducedOrderModel'):
22+
original_module.ReducedOrderModel = ParallelROM
23+
24+
# 3. Re-export the tests so pytest finds them here
25+
from tests.test_ann import *
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import pytest
3+
import sys
4+
from unittest import mock
5+
6+
# 1. Shield the imports
7+
try:
8+
from ezyrb.parallel import ReducedOrderModel as ParallelROM
9+
import tests.test_approximation as original_module
10+
HAS_PARALLEL = True
11+
except ImportError:
12+
HAS_PARALLEL = False
13+
14+
if not HAS_PARALLEL:
15+
raise unittest.SkipTest("Parallel dependencies missing")
16+
17+
# 2. The "Lazy" Swap (Monkeypatching)
18+
# We replace the ROM in the original module's namespace
19+
# so that decorators like @pytest.mark.parametrize use the Parallel version.
20+
original_module.ROM = ParallelROM
21+
if hasattr(original_module, 'ReducedOrderModel'):
22+
original_module.ReducedOrderModel = ParallelROM
23+
24+
# 3. Re-export the tests so pytest finds them here
25+
from tests.test_approximation import *
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import pytest
3+
import sys
4+
from unittest import mock
5+
6+
# 1. Shield the imports
7+
try:
8+
from ezyrb.parallel import ReducedOrderModel as ParallelROM
9+
import tests.test_database as original_module
10+
HAS_PARALLEL = True
11+
except ImportError:
12+
HAS_PARALLEL = False
13+
14+
if not HAS_PARALLEL:
15+
raise unittest.SkipTest("Parallel dependencies missing")
16+
17+
# 2. The "Lazy" Swap (Monkeypatching)
18+
# We replace the ROM in the original module's namespace
19+
# so that decorators like @pytest.mark.parametrize use the Parallel version.
20+
original_module.ROM = ParallelROM
21+
if hasattr(original_module, 'ReducedOrderModel'):
22+
original_module.ReducedOrderModel = ParallelROM
23+
24+
# 3. Re-export the tests so pytest finds them here
25+
from tests.test_database import *

tests/test_parallel/test_gpr.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import pytest
3+
import sys
4+
from unittest import mock
5+
6+
# 1. Shield the imports
7+
try:
8+
from ezyrb.parallel import ReducedOrderModel as ParallelROM
9+
import tests.test_gpr as original_module
10+
HAS_PARALLEL = True
11+
except ImportError:
12+
HAS_PARALLEL = False
13+
14+
if not HAS_PARALLEL:
15+
raise unittest.SkipTest("Parallel dependencies missing")
16+
17+
# 2. The "Lazy" Swap (Monkeypatching)
18+
# We replace the ROM in the original module's namespace
19+
# so that decorators like @pytest.mark.parametrize use the Parallel version.
20+
original_module.ROM = ParallelROM
21+
if hasattr(original_module, 'ReducedOrderModel'):
22+
original_module.ReducedOrderModel = ParallelROM
23+
24+
# 3. Re-export the tests so pytest finds them here
25+
from tests.test_gpr import *
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import pytest
3+
import sys
4+
from unittest import mock
5+
6+
# 1. Shield the imports
7+
try:
8+
from ezyrb.parallel import ReducedOrderModel as ParallelROM
9+
import tests.test_k_neighbors_regressor as original_module
10+
HAS_PARALLEL = True
11+
except ImportError:
12+
HAS_PARALLEL = False
13+
14+
if not HAS_PARALLEL:
15+
raise unittest.SkipTest("Parallel dependencies missing")
16+
17+
# 2. The "Lazy" Swap (Monkeypatching)
18+
# We replace the ROM in the original module's namespace
19+
# so that decorators like @pytest.mark.parametrize use the Parallel version.
20+
original_module.ROM = ParallelROM
21+
if hasattr(original_module, 'ReducedOrderModel'):
22+
original_module.ReducedOrderModel = ParallelROM
23+
24+
# 3. Re-export the tests so pytest finds them here
25+
from tests.test_k_neighbors_regressor import *

tests/test_parallel/test_linear.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import pytest
3+
import sys
4+
from unittest import mock
5+
6+
# 1. Shield the imports
7+
try:
8+
from ezyrb.parallel import ReducedOrderModel as ParallelROM
9+
import tests.test_linear as original_module
10+
HAS_PARALLEL = True
11+
except ImportError:
12+
HAS_PARALLEL = False
13+
14+
if not HAS_PARALLEL:
15+
raise unittest.SkipTest("Parallel dependencies missing")
16+
17+
# 2. The "Lazy" Swap (Monkeypatching)
18+
# We replace the ROM in the original module's namespace
19+
# so that decorators like @pytest.mark.parametrize use the Parallel version.
20+
original_module.ROM = ParallelROM
21+
if hasattr(original_module, 'ReducedOrderModel'):
22+
original_module.ReducedOrderModel = ParallelROM
23+
24+
# 3. Re-export the tests so pytest finds them here
25+
from tests.test_linear import *
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import pytest
3+
import sys
4+
from unittest import mock
5+
6+
# 1. Shield the imports
7+
try:
8+
from ezyrb.parallel import ReducedOrderModel as ParallelROM
9+
import tests.test_nnshift as original_module
10+
HAS_PARALLEL = True
11+
except ImportError:
12+
HAS_PARALLEL = False
13+
14+
if not HAS_PARALLEL:
15+
raise unittest.SkipTest("Parallel dependencies missing")
16+
17+
# 2. The "Lazy" Swap (Monkeypatching)
18+
# We replace the ROM in the original module's namespace
19+
# so that decorators like @pytest.mark.parametrize use the Parallel version.
20+
original_module.ROM = ParallelROM
21+
if hasattr(original_module, 'ReducedOrderModel'):
22+
original_module.ReducedOrderModel = ParallelROM
23+
24+
# 3. Re-export the tests so pytest finds them here
25+
from tests.test_nnshift import *

0 commit comments

Comments
 (0)