From d4c3a40e756b3d9e5d10823f29c72fc9c2c6e8ca Mon Sep 17 00:00:00 2001
From: PeterMeisrimelModelon
<92585725+PeterMeisrimelModelon@users.noreply.github.com>
Date: Fri, 16 Feb 2024 11:52:37 +0100
Subject: [PATCH] Removing tests from packages; moving test files to tests
folder; adding examples to testing
---
.github/workflows/build.yml | 5 +-
CHANGELOG | 2 +
setup.cfg | 7 +++
setup.py | 15 +----
src/pyfmi/examples/fmi_bouncing_ball.py | 6 +-
src/pyfmi/examples/fmi_bouncing_ball_cs.py | 2 +-
src/pyfmi/examples/fmu_with_input.py | 3 +-
src/pyfmi/{tests => }/test_util.pxd | 0
src/pyfmi/{tests => }/test_util.pyx | 2 +-
src/pyfmi/tests/__init__.py | 16 -----
.../files/FMUs/XML/CS1.0/CoupledClutches.fmu | Bin
.../files/FMUs/XML/CS1.0/NegatedAlias.fmu | Bin
.../files/FMUs/XML/CS1.0/bouncingBall.fmu | Bin
.../files/FMUs/XML/CS2.0/CoupledClutches.fmu | Bin
.../files/FMUs/XML/CS2.0/GainTestInteger.fmu | Bin
.../files/FMUs/XML/CS2.0/GainTestReal.fmu | Bin
.../files/FMUs/XML/CS2.0/IntegerStep.fmu | Bin
.../LinearCoSimulation_LinearSubSystem1.fmu | Bin
.../LinearCoSimulation_LinearSubSystem2.fmu | Bin
.../XML/CS2.0/LinearStability.SubSystem1.fmu | Bin
.../XML/CS2.0/LinearStability.SubSystem2.fmu | Bin
...LinearStability_LinearSubSystemNoFeed1.fmu | Bin
...LinearStability_LinearSubSystemNoFeed2.fmu | Bin
.../files/FMUs/XML/CS2.0/NegatedAlias.fmu | Bin
.../files/FMUs/XML/CS2.0/bouncingBall.fmu | Bin
.../files/FMUs/XML/ME1.0/Alias1.fmu | Bin
.../files/FMUs/XML/ME1.0/CoupledClutches.fmu | Bin
.../files/FMUs/XML/ME1.0/Description.fmu | Bin
.../files/FMUs/XML/ME1.0/NegatedAlias.fmu | Bin
.../files/FMUs/XML/ME1.0/NoState.Example1.fmu | Bin
.../files/FMUs/XML/ME1.0/NominalTest4.fmu | Bin
.../files/FMUs/XML/ME1.0/RLC_Circuit.fmu | Bin
.../files/FMUs/XML/ME1.0/bouncingBall.fmu | Bin
.../files/FMUs/XML/ME1.0/dq.fmu | Bin
.../files/FMUs/XML/ME2.0/Alias.fmu | Bin
.../files/FMUs/XML/ME2.0/BasicSens1.fmu | Bin
.../files/FMUs/XML/ME2.0/BasicSens2.fmu | Bin
.../files/FMUs/XML/ME2.0/Bouncing_Ball.fmu | Bin
.../files/FMUs/XML/ME2.0/CoupledClutches.fmu | Bin
.../XML/ME2.0/CoupledClutchesModified.fmu | Bin
.../files/FMUs/XML/ME2.0/Description.fmu | Bin
.../XML/ME2.0/Enumerations.Enumeration3.fmu | Bin
.../files/FMUs/XML/ME2.0/Friction2.fmu | Bin
.../files/FMUs/XML/ME2.0/Large.fmu | Bin
.../XML/ME2.0/LinearStability.FullSystem.fmu | Bin
.../XML/ME2.0/LinearStability.SubSystem1.fmu | Bin
.../XML/ME2.0/LinearStability.SubSystem2.fmu | Bin
.../files/FMUs/XML/ME2.0/LinearStateSpace.fmu | Bin
.../files/FMUs/XML/ME2.0/MalFormed.fmu | Bin
.../files/FMUs/XML/ME2.0/NegatedAlias.fmu | Bin
.../files/FMUs/XML/ME2.0/NoState.Example1.fmu | Bin
.../XML/ME2.0/NominalTests.NominalTest4.fmu | Bin
.../files/FMUs/XML/ME2.0/OutputTest2.fmu | Bin
.../files/FMUs/XML/ME2.0/ParameterAlias.fmu | Bin
.../XML/ME2.0/QuadTankPack_Sim_QuadTank.fmu | Bin
.../files/FMUs/XML/ME2.0/bouncingBall.fmu | Bin
.../FMUs/XML/ME2.0/test_type_definitions.fmu | Bin
.../files/Logs/CoupledClutches_CS_log.txt | 0
.../files/Logs/CoupledClutches_log.txt | 0
.../files/Logs/CoupledClutches_log.xml | 0
.../files/Logs/boolean_log.xml | 0
.../files/Results/DoublePendulum.mat | Bin
.../tests => tests}/files/Results/TestCSV.csv | 0
.../files/Results/qt_par_est_data.mat | Bin
tests/pytest.ini | 3 -
tests/test_examples.py | 59 ++++++++++++++++++
tests/test_fmi.py | 2 +-
tests/test_fmi_coupled.py | 4 +-
tests/test_fmi_estimate.py | 2 +-
tests/test_fmi_master.py | 2 +-
tests/test_io.py | 2 +-
tests/test_log.py | 2 +-
tests/test_stream.py | 2 +-
73 files changed, 86 insertions(+), 50 deletions(-)
rename src/pyfmi/{tests => }/test_util.pxd (100%)
rename src/pyfmi/{tests => }/test_util.pyx (99%)
delete mode 100644 src/pyfmi/tests/__init__.py
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS1.0/CoupledClutches.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS1.0/NegatedAlias.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS1.0/bouncingBall.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/CoupledClutches.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/GainTestInteger.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/GainTestReal.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/IntegerStep.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem1.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem2.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/LinearStability.SubSystem1.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/LinearStability.SubSystem2.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed1.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed2.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/NegatedAlias.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/CS2.0/bouncingBall.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME1.0/Alias1.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME1.0/CoupledClutches.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME1.0/Description.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME1.0/NegatedAlias.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME1.0/NoState.Example1.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME1.0/NominalTest4.fmu (100%)
mode change 100755 => 100644
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME1.0/RLC_Circuit.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME1.0/bouncingBall.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME1.0/dq.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/Alias.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/BasicSens1.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/BasicSens2.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/Bouncing_Ball.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/CoupledClutches.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/CoupledClutchesModified.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/Description.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/Enumerations.Enumeration3.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/Friction2.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/Large.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/LinearStability.FullSystem.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/LinearStability.SubSystem1.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/LinearStability.SubSystem2.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/LinearStateSpace.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/MalFormed.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/NegatedAlias.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/NoState.Example1.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/NominalTests.NominalTest4.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/OutputTest2.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/ParameterAlias.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/QuadTankPack_Sim_QuadTank.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/bouncingBall.fmu (100%)
rename {src/pyfmi/tests => tests}/files/FMUs/XML/ME2.0/test_type_definitions.fmu (100%)
rename {src/pyfmi/tests => tests}/files/Logs/CoupledClutches_CS_log.txt (100%)
rename {src/pyfmi/tests => tests}/files/Logs/CoupledClutches_log.txt (100%)
rename {src/pyfmi/tests => tests}/files/Logs/CoupledClutches_log.xml (100%)
rename {src/pyfmi/tests => tests}/files/Logs/boolean_log.xml (100%)
rename {src/pyfmi/tests => tests}/files/Results/DoublePendulum.mat (100%)
rename {src/pyfmi/tests => tests}/files/Results/TestCSV.csv (100%)
rename {src/pyfmi/tests => tests}/files/Results/qt_par_est_data.mat (100%)
delete mode 100644 tests/pytest.ini
create mode 100644 tests/test_examples.py
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 12bf70e9..256815cc 100755
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -56,7 +56,4 @@ jobs:
- name: Build
run: python3 setup.py install --user --fmil-home=/usr
- name: Test
- run: |
- rm src/pyfmi/__init__.py
- cp -rv src/pyfmi/tests/files tests
- pytest --verbose tests/
+ run: pytest
diff --git a/CHANGELOG b/CHANGELOG
index 643fa023..e840b4ce 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,8 @@
* Removed utilities related to the obsolete FMUX model interface.
* Removed no longer required dependency on lxml.
* Upgraded to Cython3.
+ * Switched testing framework from nose to pytest
+ * Removed submodule pyfmi.tests, tests are no longer part of the PyFMI package.
--- PyFMI-2.11.0 ---
* Refactored result handling for dynamic_diagnostics. It is now possible use dynamic_diagnostics with a custom result handler.
diff --git a/setup.cfg b/setup.cfg
index 50f3ede2..827ee2cc 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -11,3 +11,10 @@ install_requires =
pytest >= 7.4.4
matplotlib > 3
assimulo >= 3.5.0
+
+# pytest configuration
+[tool:pytest]
+addopts = -v
+testpaths = "tests"
+filterwarnings =
+ ignore:.*does not support directional derivatives.*:UserWarning
diff --git a/setup.py b/setup.py
index 74e64bf7..5389cecb 100644
--- a/setup.py
+++ b/setup.py
@@ -245,7 +245,7 @@ def check_extensions():
compiler_directives={'language_level' : "3str"})
# Test utilities
- ext_list += cythonize([os.path.join("src", "pyfmi", "tests", "test_util.pyx")],
+ ext_list += cythonize([os.path.join("src", "pyfmi", "test_util.pyx")],
include_path = incl_path,
compiler_directives={'language_level' : "3str"})
@@ -322,15 +322,13 @@ def check_extensions():
classifiers=CLASSIFIERS,
ext_modules = ext_list,
package_dir = {'pyfmi': os.path.join('src', 'pyfmi'),
- 'pyfmi.common': os.path.join('src', 'common'),
- 'pyfmi.tests': 'tests'},
+ 'pyfmi.common': os.path.join('src', 'common')},
packages=[
'pyfmi',
'pyfmi.simulation',
'pyfmi.examples',
'pyfmi.common',
'pyfmi.common.plotting',
- 'pyfmi.tests',
'pyfmi.common.log'
],
package_data = {'pyfmi': [
@@ -338,17 +336,10 @@ def check_extensions():
'examples/files/FMUs/CS1.0/*',
'examples/files/FMUs/ME2.0/*',
'examples/files/FMUs/CS2.0/*',
- 'tests/files/FMUs/XML/ME1.0/*',
- 'tests/files/FMUs/XML/CS1.0/*',
- 'tests/files/FMUs/XML/ME2.0/*',
- 'tests/files/FMUs/XML/CS2.0/*',
- 'tests/files/Results/*',
- 'tests/files/Logs/*',
'version.txt',
'LICENSE',
'CHANGELOG',
- 'util/*'] + extra_package_data,
- 'pyfmi.tests': ['pytest.ini']},
+ 'util/*'] + extra_package_data},
script_args=copy_args
)
diff --git a/src/pyfmi/examples/fmi_bouncing_ball.py b/src/pyfmi/examples/fmi_bouncing_ball.py
index d7b4b658..a91ddb58 100644
--- a/src/pyfmi/examples/fmi_bouncing_ball.py
+++ b/src/pyfmi/examples/fmi_bouncing_ball.py
@@ -21,7 +21,7 @@
from pyfmi import load_fmu
-curr_dir = os.path.dirname(os.path.abspath(__file__));
+curr_dir = os.path.dirname(os.path.abspath(__file__))
path_to_fmus = os.path.join(curr_dir, 'files', 'FMUs','ME1.0')
path_to_fmus2 = os.path.join(curr_dir, 'files', 'FMUs','ME2.0')
@@ -31,9 +31,9 @@ def run_demo(with_plots=True, version="2.0"):
ME FMUs version 1.0 and 2.0.
"""
if version == '1.0':
- fmu_name = os.path.join(path_to_fmus,'bouncingBall.fmu')
+ fmu_name = os.path.join(path_to_fmus, 'bouncingBall.fmu')
else:
- fmu_name = os.path.join(path_to_fmus2,'bouncingBall.fmu')
+ fmu_name = os.path.join(path_to_fmus2, 'bouncingBall.fmu')
model = load_fmu(fmu_name)
diff --git a/src/pyfmi/examples/fmi_bouncing_ball_cs.py b/src/pyfmi/examples/fmi_bouncing_ball_cs.py
index 5008adbc..096328c5 100644
--- a/src/pyfmi/examples/fmi_bouncing_ball_cs.py
+++ b/src/pyfmi/examples/fmi_bouncing_ball_cs.py
@@ -21,7 +21,7 @@
from pyfmi import load_fmu
-curr_dir = os.path.dirname(os.path.abspath(__file__));
+curr_dir = os.path.dirname(os.path.abspath(__file__))
path_to_fmus = os.path.join(curr_dir, 'files', 'FMUs', 'CS1.0')
path_to_fmus2 = os.path.join(curr_dir, 'files', 'FMUs', 'CS2.0')
diff --git a/src/pyfmi/examples/fmu_with_input.py b/src/pyfmi/examples/fmu_with_input.py
index 985233f5..c8039b4c 100644
--- a/src/pyfmi/examples/fmu_with_input.py
+++ b/src/pyfmi/examples/fmu_with_input.py
@@ -32,7 +32,7 @@ def run_demo(with_plots=True):
See also simulation_with_input.py
"""
- fmu_name = os.path.join(path_to_fmus_me1,'SecondOrder.fmu')
+ fmu_name = os.path.join(path_to_fmus_me1, 'SecondOrder.fmu')
# Generate input
t = np.linspace(0.,10.,100)
@@ -70,4 +70,3 @@ def run_demo(with_plots=True):
if __name__=="__main__":
run_demo()
-
diff --git a/src/pyfmi/tests/test_util.pxd b/src/pyfmi/test_util.pxd
similarity index 100%
rename from src/pyfmi/tests/test_util.pxd
rename to src/pyfmi/test_util.pxd
diff --git a/src/pyfmi/tests/test_util.pyx b/src/pyfmi/test_util.pyx
similarity index 99%
rename from src/pyfmi/tests/test_util.pyx
rename to src/pyfmi/test_util.pyx
index 95f2ebe9..e697ece9 100644
--- a/src/pyfmi/tests/test_util.pyx
+++ b/src/pyfmi/test_util.pyx
@@ -24,7 +24,7 @@ cimport pyfmi.fmil_import as FMIL
from pyfmi.fmi import FMUException, FMUModelME1, FMUModelCS1, FMUModelCS2, FMUModelME2
def get_examples_folder():
- return os.path.join(os.path.dirname(__file__), '..', 'examples')
+ return os.path.join(os.path.dirname(__file__), 'examples')
cdef class _ForTestingFMUModelME1(FMUModelME1):
cdef int _get_nominal_continuous_states_fmil(self, FMIL.fmi1_real_t* xnominal, size_t nx):
diff --git a/src/pyfmi/tests/__init__.py b/src/pyfmi/tests/__init__.py
deleted file mode 100644
index 8962836d..00000000
--- a/src/pyfmi/tests/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# Copyright (C) 2024 Modelon AB
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation, version 3 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program. If not, see .
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS1.0/CoupledClutches.fmu b/tests/files/FMUs/XML/CS1.0/CoupledClutches.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS1.0/CoupledClutches.fmu
rename to tests/files/FMUs/XML/CS1.0/CoupledClutches.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS1.0/NegatedAlias.fmu b/tests/files/FMUs/XML/CS1.0/NegatedAlias.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS1.0/NegatedAlias.fmu
rename to tests/files/FMUs/XML/CS1.0/NegatedAlias.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS1.0/bouncingBall.fmu b/tests/files/FMUs/XML/CS1.0/bouncingBall.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS1.0/bouncingBall.fmu
rename to tests/files/FMUs/XML/CS1.0/bouncingBall.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/CoupledClutches.fmu b/tests/files/FMUs/XML/CS2.0/CoupledClutches.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/CoupledClutches.fmu
rename to tests/files/FMUs/XML/CS2.0/CoupledClutches.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/GainTestInteger.fmu b/tests/files/FMUs/XML/CS2.0/GainTestInteger.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/GainTestInteger.fmu
rename to tests/files/FMUs/XML/CS2.0/GainTestInteger.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/GainTestReal.fmu b/tests/files/FMUs/XML/CS2.0/GainTestReal.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/GainTestReal.fmu
rename to tests/files/FMUs/XML/CS2.0/GainTestReal.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/IntegerStep.fmu b/tests/files/FMUs/XML/CS2.0/IntegerStep.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/IntegerStep.fmu
rename to tests/files/FMUs/XML/CS2.0/IntegerStep.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem1.fmu b/tests/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem1.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem1.fmu
rename to tests/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem1.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem2.fmu b/tests/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem2.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem2.fmu
rename to tests/files/FMUs/XML/CS2.0/LinearCoSimulation_LinearSubSystem2.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearStability.SubSystem1.fmu b/tests/files/FMUs/XML/CS2.0/LinearStability.SubSystem1.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearStability.SubSystem1.fmu
rename to tests/files/FMUs/XML/CS2.0/LinearStability.SubSystem1.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearStability.SubSystem2.fmu b/tests/files/FMUs/XML/CS2.0/LinearStability.SubSystem2.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearStability.SubSystem2.fmu
rename to tests/files/FMUs/XML/CS2.0/LinearStability.SubSystem2.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed1.fmu b/tests/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed1.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed1.fmu
rename to tests/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed1.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed2.fmu b/tests/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed2.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed2.fmu
rename to tests/files/FMUs/XML/CS2.0/LinearStability_LinearSubSystemNoFeed2.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/NegatedAlias.fmu b/tests/files/FMUs/XML/CS2.0/NegatedAlias.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/NegatedAlias.fmu
rename to tests/files/FMUs/XML/CS2.0/NegatedAlias.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/CS2.0/bouncingBall.fmu b/tests/files/FMUs/XML/CS2.0/bouncingBall.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/CS2.0/bouncingBall.fmu
rename to tests/files/FMUs/XML/CS2.0/bouncingBall.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME1.0/Alias1.fmu b/tests/files/FMUs/XML/ME1.0/Alias1.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME1.0/Alias1.fmu
rename to tests/files/FMUs/XML/ME1.0/Alias1.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME1.0/CoupledClutches.fmu b/tests/files/FMUs/XML/ME1.0/CoupledClutches.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME1.0/CoupledClutches.fmu
rename to tests/files/FMUs/XML/ME1.0/CoupledClutches.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME1.0/Description.fmu b/tests/files/FMUs/XML/ME1.0/Description.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME1.0/Description.fmu
rename to tests/files/FMUs/XML/ME1.0/Description.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME1.0/NegatedAlias.fmu b/tests/files/FMUs/XML/ME1.0/NegatedAlias.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME1.0/NegatedAlias.fmu
rename to tests/files/FMUs/XML/ME1.0/NegatedAlias.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME1.0/NoState.Example1.fmu b/tests/files/FMUs/XML/ME1.0/NoState.Example1.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME1.0/NoState.Example1.fmu
rename to tests/files/FMUs/XML/ME1.0/NoState.Example1.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME1.0/NominalTest4.fmu b/tests/files/FMUs/XML/ME1.0/NominalTest4.fmu
old mode 100755
new mode 100644
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME1.0/NominalTest4.fmu
rename to tests/files/FMUs/XML/ME1.0/NominalTest4.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME1.0/RLC_Circuit.fmu b/tests/files/FMUs/XML/ME1.0/RLC_Circuit.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME1.0/RLC_Circuit.fmu
rename to tests/files/FMUs/XML/ME1.0/RLC_Circuit.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME1.0/bouncingBall.fmu b/tests/files/FMUs/XML/ME1.0/bouncingBall.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME1.0/bouncingBall.fmu
rename to tests/files/FMUs/XML/ME1.0/bouncingBall.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME1.0/dq.fmu b/tests/files/FMUs/XML/ME1.0/dq.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME1.0/dq.fmu
rename to tests/files/FMUs/XML/ME1.0/dq.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/Alias.fmu b/tests/files/FMUs/XML/ME2.0/Alias.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/Alias.fmu
rename to tests/files/FMUs/XML/ME2.0/Alias.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/BasicSens1.fmu b/tests/files/FMUs/XML/ME2.0/BasicSens1.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/BasicSens1.fmu
rename to tests/files/FMUs/XML/ME2.0/BasicSens1.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/BasicSens2.fmu b/tests/files/FMUs/XML/ME2.0/BasicSens2.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/BasicSens2.fmu
rename to tests/files/FMUs/XML/ME2.0/BasicSens2.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/Bouncing_Ball.fmu b/tests/files/FMUs/XML/ME2.0/Bouncing_Ball.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/Bouncing_Ball.fmu
rename to tests/files/FMUs/XML/ME2.0/Bouncing_Ball.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/CoupledClutches.fmu b/tests/files/FMUs/XML/ME2.0/CoupledClutches.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/CoupledClutches.fmu
rename to tests/files/FMUs/XML/ME2.0/CoupledClutches.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/CoupledClutchesModified.fmu b/tests/files/FMUs/XML/ME2.0/CoupledClutchesModified.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/CoupledClutchesModified.fmu
rename to tests/files/FMUs/XML/ME2.0/CoupledClutchesModified.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/Description.fmu b/tests/files/FMUs/XML/ME2.0/Description.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/Description.fmu
rename to tests/files/FMUs/XML/ME2.0/Description.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/Enumerations.Enumeration3.fmu b/tests/files/FMUs/XML/ME2.0/Enumerations.Enumeration3.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/Enumerations.Enumeration3.fmu
rename to tests/files/FMUs/XML/ME2.0/Enumerations.Enumeration3.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/Friction2.fmu b/tests/files/FMUs/XML/ME2.0/Friction2.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/Friction2.fmu
rename to tests/files/FMUs/XML/ME2.0/Friction2.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/Large.fmu b/tests/files/FMUs/XML/ME2.0/Large.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/Large.fmu
rename to tests/files/FMUs/XML/ME2.0/Large.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/LinearStability.FullSystem.fmu b/tests/files/FMUs/XML/ME2.0/LinearStability.FullSystem.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/LinearStability.FullSystem.fmu
rename to tests/files/FMUs/XML/ME2.0/LinearStability.FullSystem.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/LinearStability.SubSystem1.fmu b/tests/files/FMUs/XML/ME2.0/LinearStability.SubSystem1.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/LinearStability.SubSystem1.fmu
rename to tests/files/FMUs/XML/ME2.0/LinearStability.SubSystem1.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/LinearStability.SubSystem2.fmu b/tests/files/FMUs/XML/ME2.0/LinearStability.SubSystem2.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/LinearStability.SubSystem2.fmu
rename to tests/files/FMUs/XML/ME2.0/LinearStability.SubSystem2.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/LinearStateSpace.fmu b/tests/files/FMUs/XML/ME2.0/LinearStateSpace.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/LinearStateSpace.fmu
rename to tests/files/FMUs/XML/ME2.0/LinearStateSpace.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/MalFormed.fmu b/tests/files/FMUs/XML/ME2.0/MalFormed.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/MalFormed.fmu
rename to tests/files/FMUs/XML/ME2.0/MalFormed.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/NegatedAlias.fmu b/tests/files/FMUs/XML/ME2.0/NegatedAlias.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/NegatedAlias.fmu
rename to tests/files/FMUs/XML/ME2.0/NegatedAlias.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/NoState.Example1.fmu b/tests/files/FMUs/XML/ME2.0/NoState.Example1.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/NoState.Example1.fmu
rename to tests/files/FMUs/XML/ME2.0/NoState.Example1.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/NominalTests.NominalTest4.fmu b/tests/files/FMUs/XML/ME2.0/NominalTests.NominalTest4.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/NominalTests.NominalTest4.fmu
rename to tests/files/FMUs/XML/ME2.0/NominalTests.NominalTest4.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/OutputTest2.fmu b/tests/files/FMUs/XML/ME2.0/OutputTest2.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/OutputTest2.fmu
rename to tests/files/FMUs/XML/ME2.0/OutputTest2.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/ParameterAlias.fmu b/tests/files/FMUs/XML/ME2.0/ParameterAlias.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/ParameterAlias.fmu
rename to tests/files/FMUs/XML/ME2.0/ParameterAlias.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/QuadTankPack_Sim_QuadTank.fmu b/tests/files/FMUs/XML/ME2.0/QuadTankPack_Sim_QuadTank.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/QuadTankPack_Sim_QuadTank.fmu
rename to tests/files/FMUs/XML/ME2.0/QuadTankPack_Sim_QuadTank.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/bouncingBall.fmu b/tests/files/FMUs/XML/ME2.0/bouncingBall.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/bouncingBall.fmu
rename to tests/files/FMUs/XML/ME2.0/bouncingBall.fmu
diff --git a/src/pyfmi/tests/files/FMUs/XML/ME2.0/test_type_definitions.fmu b/tests/files/FMUs/XML/ME2.0/test_type_definitions.fmu
similarity index 100%
rename from src/pyfmi/tests/files/FMUs/XML/ME2.0/test_type_definitions.fmu
rename to tests/files/FMUs/XML/ME2.0/test_type_definitions.fmu
diff --git a/src/pyfmi/tests/files/Logs/CoupledClutches_CS_log.txt b/tests/files/Logs/CoupledClutches_CS_log.txt
similarity index 100%
rename from src/pyfmi/tests/files/Logs/CoupledClutches_CS_log.txt
rename to tests/files/Logs/CoupledClutches_CS_log.txt
diff --git a/src/pyfmi/tests/files/Logs/CoupledClutches_log.txt b/tests/files/Logs/CoupledClutches_log.txt
similarity index 100%
rename from src/pyfmi/tests/files/Logs/CoupledClutches_log.txt
rename to tests/files/Logs/CoupledClutches_log.txt
diff --git a/src/pyfmi/tests/files/Logs/CoupledClutches_log.xml b/tests/files/Logs/CoupledClutches_log.xml
similarity index 100%
rename from src/pyfmi/tests/files/Logs/CoupledClutches_log.xml
rename to tests/files/Logs/CoupledClutches_log.xml
diff --git a/src/pyfmi/tests/files/Logs/boolean_log.xml b/tests/files/Logs/boolean_log.xml
similarity index 100%
rename from src/pyfmi/tests/files/Logs/boolean_log.xml
rename to tests/files/Logs/boolean_log.xml
diff --git a/src/pyfmi/tests/files/Results/DoublePendulum.mat b/tests/files/Results/DoublePendulum.mat
similarity index 100%
rename from src/pyfmi/tests/files/Results/DoublePendulum.mat
rename to tests/files/Results/DoublePendulum.mat
diff --git a/src/pyfmi/tests/files/Results/TestCSV.csv b/tests/files/Results/TestCSV.csv
similarity index 100%
rename from src/pyfmi/tests/files/Results/TestCSV.csv
rename to tests/files/Results/TestCSV.csv
diff --git a/src/pyfmi/tests/files/Results/qt_par_est_data.mat b/tests/files/Results/qt_par_est_data.mat
similarity index 100%
rename from src/pyfmi/tests/files/Results/qt_par_est_data.mat
rename to tests/files/Results/qt_par_est_data.mat
diff --git a/tests/pytest.ini b/tests/pytest.ini
deleted file mode 100644
index 9cce0b8d..00000000
--- a/tests/pytest.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[pytest]
-filterwarnings =
- ignore:.*does not support directional derivatives.*:UserWarning
diff --git a/tests/test_examples.py b/tests/test_examples.py
new file mode 100644
index 00000000..1dee291a
--- /dev/null
+++ b/tests/test_examples.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2024 Modelon AB
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see .
+
+import pytest
+import os
+import pylab as pl
+
+from pyfmi.examples import (
+ fmi_bouncing_ball_native,
+ fmi20_bouncing_ball_native,
+ fmi_bouncing_ball,
+ fmi_bouncing_ball_cs,
+ fmu_with_input,
+ fmu_with_input_function
+)
+
+@pytest.mark.parametrize("example", [
+ fmi_bouncing_ball_native,
+ fmi20_bouncing_ball_native
+])
+def test_run_example_bouncing_ball_native(example):
+ """Test pyfmi bouncing ball native examples."""
+ example.run_demo()
+ pl.close("all") # close all generated figures
+
+@pytest.mark.parametrize("fmi_version", ["1.0", "2.0"])
+@pytest.mark.parametrize("example", [
+ fmi_bouncing_ball,
+ fmi_bouncing_ball_cs
+])
+def test_run_example_bouncing_ball(example, fmi_version):
+ """Test pyfmi bouncing ball example in various versions."""
+ example.run_demo(version = fmi_version)
+ pl.close("all") # close all generated figures
+
+@pytest.mark.skipif("nt" not in os.name,
+ reason = "FMU is example only contains windows binaries")
+@pytest.mark.parametrize("example", [
+ fmu_with_input,
+ fmu_with_input_function
+])
+def test_run_example_with_input(example):
+ """Test pyfmi examples with input."""
+ example.run_demo()
+ pl.close("all") # close all generated figures
diff --git a/tests/test_fmi.py b/tests/test_fmi.py
index 81070121..b5baa258 100644
--- a/tests/test_fmi.py
+++ b/tests/test_fmi.py
@@ -28,7 +28,7 @@
import pyfmi.fmi as fmi
from pyfmi.fmi_algorithm_drivers import AssimuloFMIAlg, AssimuloFMIAlgOptions, \
PYFMI_JACOBIAN_LIMIT, PYFMI_JACOBIAN_SPARSE_SIZE_LIMIT
-from pyfmi.tests.test_util import Dummy_FMUModelCS1, Dummy_FMUModelME1, Dummy_FMUModelME2, Dummy_FMUModelCS2, get_examples_folder
+from pyfmi.test_util import Dummy_FMUModelCS1, Dummy_FMUModelME1, Dummy_FMUModelME2, Dummy_FMUModelCS2, get_examples_folder
from pyfmi.common.io import ResultHandler
from pyfmi.common.algorithm_drivers import UnrecognizedOptionError
from pyfmi.common.core import create_temp_dir
diff --git a/tests/test_fmi_coupled.py b/tests/test_fmi_coupled.py
index 08899f8a..23ab584d 100644
--- a/tests/test_fmi_coupled.py
+++ b/tests/test_fmi_coupled.py
@@ -18,10 +18,10 @@
import pytest
import os
+import pyfmi.fmi as fmi
from pyfmi.fmi import FMUModelME2
from pyfmi.fmi_coupled import CoupledFMUModelME2
-import pyfmi.fmi as fmi
-from pyfmi.tests.test_util import Dummy_FMUModelME2
+from pyfmi.test_util import Dummy_FMUModelME2
assimulo_installed = True
try:
diff --git a/tests/test_fmi_estimate.py b/tests/test_fmi_estimate.py
index 7477dd0b..38d95ac9 100644
--- a/tests/test_fmi_estimate.py
+++ b/tests/test_fmi_estimate.py
@@ -18,7 +18,7 @@
import os
import numpy as np
-from pyfmi.tests.test_util import Dummy_FMUModelME2
+from pyfmi.test_util import Dummy_FMUModelME2
from scipy.io.matlab import loadmat
assimulo_installed = True
diff --git a/tests/test_fmi_master.py b/tests/test_fmi_master.py
index 75e1f38b..6b4792d6 100644
--- a/tests/test_fmi_master.py
+++ b/tests/test_fmi_master.py
@@ -21,7 +21,7 @@
from pyfmi import Master
from pyfmi.fmi import FMUException, FMUModelCS2, FMUModelME2
-from pyfmi.tests.test_util import Dummy_FMUModelCS2
+from pyfmi.test_util import Dummy_FMUModelCS2
from pyfmi.common.algorithm_drivers import UnrecognizedOptionError
file_path = os.path.dirname(os.path.abspath(__file__))
diff --git a/tests/test_io.py b/tests/test_io.py
index 71598453..9a04540c 100644
--- a/tests/test_io.py
+++ b/tests/test_io.py
@@ -28,7 +28,7 @@
from pyfmi.common.diagnostics import DIAGNOSTICS_PREFIX
import pyfmi.fmi as fmi
-from pyfmi.tests.test_util import Dummy_FMUModelME1, Dummy_FMUModelCS1, Dummy_FMUModelME2, Dummy_FMUModelCS2
+from pyfmi.test_util import Dummy_FMUModelME1, Dummy_FMUModelCS1, Dummy_FMUModelME2, Dummy_FMUModelCS2
file_path = os.path.dirname(os.path.abspath(__file__))
diff --git a/tests/test_log.py b/tests/test_log.py
index 38f26d7d..1be39893 100644
--- a/tests/test_log.py
+++ b/tests/test_log.py
@@ -19,7 +19,7 @@
from pyfmi.common.log import extract_xml_log, parse_xml_log
from pyfmi.common.diagnostics import DIAGNOSTICS_PREFIX
-from pyfmi.tests.test_util import Dummy_FMUModelME2
+from pyfmi.test_util import Dummy_FMUModelME2
from pyfmi.fmi_util import decode
import numpy as np
diff --git a/tests/test_stream.py b/tests/test_stream.py
index fd8be522..c821fe28 100644
--- a/tests/test_stream.py
+++ b/tests/test_stream.py
@@ -23,7 +23,7 @@
from filecmp import cmp as compare_files
from pyfmi.fmi import FMUException, load_fmu, FMUModelCS2, FMUModelME2
-from pyfmi.tests.test_util import get_examples_folder
+from pyfmi.test_util import get_examples_folder
file_path = os.path.dirname(os.path.abspath(__file__))