Skip to content

Some tests fail silently when testing overloaded methods #802

@bryanwweber

Description

@bryanwweber

System information

  • Cantera version: master
  • OS: macOS
  • Python/MATLAB version: 3.8 (but not relevant)

Expected behavior

Tests pass

Actual behavior

Some tests fail

To Reproduce

  1. scons build
  2. PYTHONPATH=build/python python -m unittest -v cantera.test.test_composite.TestModels.test_load_thermo_models

Output:

test_load_thermo_models (cantera.test.test_composite.TestModels) ... DeprecationWarning: IdealMolalSoln::setDensity: Overloaded function to be removed after Cantera 2.5. Error will be thrown by Phase::setDensity instead
ERROR

======================================================================
ERROR: test_load_thermo_models (cantera.test.test_composite.TestModels)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/bryan/GitHub/cantera/build/python/cantera/test/test_composite.py", line 45, in test_load_thermo_models
    sol.TD = TD
  File "/Users/bryan/.pyenv/versions/3.8.0/lib/python3.8/unittest/case.py", line 227, in __exit__
    self._raiseFailure("{} not raised".format(exc_name))
  File "/Users/bryan/.pyenv/versions/3.8.0/lib/python3.8/unittest/case.py", line 164, in _raiseFailure
    raise self.test_case.failureException(msg)
AssertionError: CanteraError not raised

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/bryan/GitHub/cantera/build/python/cantera/test/test_composite.py", line 65, in test_load_thermo_models
    raise TypeError(msg) from inst
TypeError: Error in processing of phase 'ideal-molal-aqueous' with type 'ideal-molal-solution'
TPX = (298.15, 101325.0, array([9.97484245e-01, 1.79696787e-03, 5.39090360e-04, 1.79696787e-04]))

----------------------------------------------------------------------
Ran 1 test in 0.280s

FAILED (errors=1)

Also

PYTHONPATH=build/python ipython
Python 3.8.0 (default, Oct 21 2019, 10:04:23)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.11.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import cantera as ct
In [2]: g = ct.Solution('test/data/thermo-models.yaml', 'ideal-molal-aqueous')
In [3]: g.is_compressible
Out[3]: False
In [6]: T, D = g.TD
In [7]: g.TD = T, D
DeprecationWarning: IdealMolalSoln::setDensity: Overloaded function to be removed after Cantera 2.5. Error will be thrown by Phase::setDensity instead

and no error is thrown.

This can also be seen in the builds for the conda packages: https://travis-ci.org/Cantera/conda-recipes/jobs/637035389#L5088

When all the tests are run (using either scons test or scons test-python) this test passes. The difference is calling unittest explicitly, which is done both in my reproduction and in the conda builds.

I think the warning about the overloaded method means that the method that actually raises this error is not called, so we should not be testing for the error condition yet. @ischoegl this is related to your work in #720. Do you have any thoughts here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions