From 10434078383cc2fb00daef537c4ff7d1202fe48c Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 18 May 2020 23:58:52 -0400 Subject: [PATCH] Fix python test with input file --- contrib/python-bindings/source/triangulation_wrapper.cc | 1 + contrib/python-bindings/tests/CMakeLists.txt | 3 +++ contrib/python-bindings/tests/manifold_wrapper.py | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/contrib/python-bindings/source/triangulation_wrapper.cc b/contrib/python-bindings/source/triangulation_wrapper.cc index 6a93a3977f..98a71a1fb7 100644 --- a/contrib/python-bindings/source/triangulation_wrapper.cc +++ b/contrib/python-bindings/source/triangulation_wrapper.cc @@ -781,6 +781,7 @@ namespace python GridIn mesh_reader; mesh_reader.attach_triangulation(*tria); std::ifstream ifs(filename); + AssertThrow(ifs, ExcIO()); mesh_reader.read(ifs, input_format); ifs.close(); } diff --git a/contrib/python-bindings/tests/CMakeLists.txt b/contrib/python-bindings/tests/CMakeLists.txt index f010303ca7..a9187973f1 100644 --- a/contrib/python-bindings/tests/CMakeLists.txt +++ b/contrib/python-bindings/tests/CMakeLists.txt @@ -22,9 +22,12 @@ ENABLE_TESTING() FILE(GLOB _tests "${CMAKE_CURRENT_SOURCE_DIR}/*.py") FOREACH(_test_path ${_tests}) GET_FILENAME_COMPONENT(_test ${_test_path} NAME_WE) + GET_FILENAME_COMPONENT(_test_directory ${_test_path} DIRECTORY) ADD_TEST(NAME python-bindings/${_test} COMMAND ${PYTHON_EXECUTABLE} ${_test_path}) SET_TESTS_PROPERTIES(python-bindings/${_test} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_BINARY_DIR}/${DEAL_II_PYTHON_RELDIR}/../:$ENV{PYTHONPATH} + ENVIRONMENT + DEAL_II_PYTHON_TESTPATH=${_test_directory} ) ENDFOREACH() diff --git a/contrib/python-bindings/tests/manifold_wrapper.py b/contrib/python-bindings/tests/manifold_wrapper.py index 947af53915..3ce9ef7cd0 100644 --- a/contrib/python-bindings/tests/manifold_wrapper.py +++ b/contrib/python-bindings/tests/manifold_wrapper.py @@ -14,6 +14,7 @@ # --------------------------------------------------------------------- import math +import os import unittest from PyDealII.Debug import * @@ -78,7 +79,8 @@ class TestManifoldWrapperFunction(unittest.TestCase): lambda p: [math.sqrt(p[0]), math.sqrt(p[1])] ) self.tria_reference = Triangulation('2D') - self.tria_reference.read('manifold_wrapper.vtk', 'vtk') + test_directory = os.environ.get('DEAL_II_PYTHON_TESTPATH') + self.tria_reference.read(test_directory+'/manifold_wrapper.vtk', 'vtk') def test_manifold_str(self): self.triangulation = Triangulation('2D') -- 2.39.5