Commit a638163a authored by Markus Holzer's avatar Markus Holzer
Browse files

Corrected datahandling test case

parent d0a1396b
import os import os
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
from pathlib import Path
import numpy as np import numpy as np
...@@ -12,6 +13,9 @@ except ImportError: ...@@ -12,6 +13,9 @@ except ImportError:
import unittest.mock import unittest.mock
pytest = unittest.mock.MagicMock() pytest = unittest.mock.MagicMock()
SCRIPT_FOLDER = Path(__file__).parent
INPUT_FOLDER = SCRIPT_FOLDER / "test_data"
def basic_iteration(dh): def basic_iteration(dh):
dh.add_array('basic_iter_test_gl_default') dh.add_array('basic_iter_test_gl_default')
...@@ -321,7 +325,7 @@ def test_save_data(): ...@@ -321,7 +325,7 @@ def test_save_data():
dh.add_array("dst", values_per_cell=9) dh.add_array("dst", values_per_cell=9)
dh.fill("dst", 1.0, ghost_layers=True) dh.fill("dst", 1.0, ghost_layers=True)
dh.save_all('test_data/datahandling_save_test') dh.save_all(INPUT_FOLDER.name + '/datahandling_save_test')
def test_load_data(): def test_load_data():
...@@ -333,7 +337,7 @@ def test_load_data(): ...@@ -333,7 +337,7 @@ def test_load_data():
dh.add_array("dst", values_per_cell=9) dh.add_array("dst", values_per_cell=9)
dh.fill("dst", 0.0, ghost_layers=True) dh.fill("dst", 0.0, ghost_layers=True)
dh.load_all('test_data/datahandling_load_test') dh.load_all(INPUT_FOLDER.name + '/datahandling_load_test')
assert np.all(dh.cpu_arrays['src']) == 1 assert np.all(dh.cpu_arrays['src']) == 1
assert np.all(dh.cpu_arrays['dst']) == 1 assert np.all(dh.cpu_arrays['dst']) == 1
...@@ -347,7 +351,7 @@ def test_load_data(): ...@@ -347,7 +351,7 @@ def test_load_data():
dh.add_array("dst2", values_per_cell=9) dh.add_array("dst2", values_per_cell=9)
dh.fill("dst2", 0.0, ghost_layers=True) dh.fill("dst2", 0.0, ghost_layers=True)
dh.load_all('test_data/datahandling_load_test') dh.load_all(INPUT_FOLDER.name + '/datahandling_load_test')
assert np.all(dh.cpu_arrays['src']) == 0 assert np.all(dh.cpu_arrays['src']) == 0
assert np.all(dh.cpu_arrays['dst']) == 0 assert np.all(dh.cpu_arrays['dst']) == 0
assert np.all(dh.cpu_arrays['dst2']) == 0 assert np.all(dh.cpu_arrays['dst2']) == 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment