From dced8fbcad5c0191c6ae98d096e2eb9c31bf5b13 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Tue, 25 Jun 2019 11:57:27 -0400 Subject: [PATCH] [Test] Make testing of deprecated methods possible Fatal deprecation warnings are useful for identifying inadvertent use of deprecated features. However, we still want to retain tests of deprecated features until those features are removed. --- interfaces/cython/cantera/_cantera.pxd | 1 + interfaces/cython/cantera/utils.pyx | 3 +++ src/base/application.h | 1 + test/thermo/thermoFromYaml.cpp | 2 ++ 4 files changed, 7 insertions(+) diff --git a/interfaces/cython/cantera/_cantera.pxd b/interfaces/cython/cantera/_cantera.pxd index 049f3c1fc..cdcc08bf0 100644 --- a/interfaces/cython/cantera/_cantera.pxd +++ b/interfaces/cython/cantera/_cantera.pxd @@ -71,6 +71,7 @@ cdef extern from "cantera/base/global.h" namespace "Cantera": cdef XML_Node* CxxGetXmlFile "Cantera::get_XML_File" (string) except +translate_exception cdef XML_Node* CxxGetXmlFromString "Cantera::get_XML_from_string" (string) except +translate_exception cdef void Cxx_make_deprecation_warnings_fatal "Cantera::make_deprecation_warnings_fatal" () + cdef void Cxx_suppress_deprecation_warnings "Cantera::suppress_deprecation_warnings" () cdef void Cxx_suppress_thermo_warnings "Cantera::suppress_thermo_warnings" (cbool) cdef string CxxGitCommit "Cantera::gitCommit" () diff --git a/interfaces/cython/cantera/utils.pyx b/interfaces/cython/cantera/utils.pyx index 4d927615d..0e2f80a7b 100644 --- a/interfaces/cython/cantera/utils.pyx +++ b/interfaces/cython/cantera/utils.pyx @@ -40,6 +40,9 @@ def appdelete(): def make_deprecation_warnings_fatal(): Cxx_make_deprecation_warnings_fatal() +def suppress_deprecation_warnings(): + Cxx_suppress_deprecation_warnings() + def suppress_thermo_warnings(pybool suppress=True): Cxx_suppress_thermo_warnings(suppress) diff --git a/src/base/application.h b/src/base/application.h index e268da1e2..0f7946a72 100644 --- a/src/base/application.h +++ b/src/base/application.h @@ -338,6 +338,7 @@ public: //! prevent certain tests from failing. void suppress_deprecation_warnings() { m_suppress_deprecation_warnings = true; + m_fatal_deprecation_warnings = false; } //! Turns deprecation warnings into exceptions. Activated within the test diff --git a/test/thermo/thermoFromYaml.cpp b/test/thermo/thermoFromYaml.cpp index 2d47898c6..f377256ea 100644 --- a/test/thermo/thermoFromYaml.cpp +++ b/test/thermo/thermoFromYaml.cpp @@ -335,8 +335,10 @@ TEST(ThermoFromYaml, PureFluid_nitrogen) TEST(ThermoFromYaml, ConstDensityThermo) { + suppress_deprecation_warnings(); auto thermo = newThermo("thermo-models.yaml", "const-density"); EXPECT_DOUBLE_EQ(thermo->density(), 700.0); + make_deprecation_warnings_fatal(); } TEST(ThermoFromYaml, IdealSolidSolnPhase)