From 1cfa6d44d9fb2332de356a32b05b1b9e9a7580d1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 28 Jun 2020 11:50:28 +0200 Subject: [PATCH] dummy version could be useful for other tests note that monkey patching requires direct access to damask.version in the respective modules. 'from xx import yy' creates a copy (at least for the version string). --- python/tests/conftest.py | 5 +++++ python/tests/test_Colormap.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/python/tests/conftest.py b/python/tests/conftest.py index 411c07a8c..a7bc59f98 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -2,6 +2,11 @@ import os import pytest +# Use to monkeypatch damask.version (for comparsion to reference files that contain version information) +def pytest_configure(): + pytest.dummy_version = '99.99.99-9999-pytest' + + def pytest_addoption(parser): parser.addoption("--update", action="store_true", diff --git a/python/tests/test_Colormap.py b/python/tests/test_Colormap.py index b95d23a86..8d3d51018 100644 --- a/python/tests/test_Colormap.py +++ b/python/tests/test_Colormap.py @@ -127,7 +127,7 @@ class TestColormap: ('Gmsh','.msh') ]) def test_compare_reference(self,format,ext,tmpdir,reference_dir,update,monkeypatch): - monkeypatch.setattr(damask, 'version', '99.99.99-9999-pytest') + monkeypatch.setattr(damask, 'version', pytest.dummy_version) name = 'binary' c = Colormap.from_predefined(name) if update: