-
-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Portable python tests #381
Conversation
The advantage of having the working directory in particular as a class attribute is that it can be removed in the class teardown |
The build failures are due to Python 2 vs 3 differences. I'll have to fix it tomorrow; I think the best solution will be to move the extra |
Well, creating a new |
42d936e
to
57b6838
Compare
@@ -33,7 +33,7 @@ def test_mixtureAveraged(self): | |||
self.assertArrayNear(Dbin1, Dbin1.T) | |||
|
|||
def test_multiComponent(self): | |||
with self.assertRaises(Exception): | |||
with self.assertRaises(AttributeError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I think the test here is wrong. The thing that we meant to test there is that multi_diff_coeffs
raises an error from Cantera if we are not using a multicomponent model, but of course the typo in the property name also raises Exception
, so this is a good example of why it was good to add the CanteraError
Python class.
To make debugging failing tests easier, it would be nice if there were a way to use |
57b6838
to
e4dfa16
Compare
So the best idea I could come up with to check whether this is an in-source test was to look for |
This is a rewrite of #376. The implementation is very similar, relying on a temp directory to store working files, instead of a user directory. I thought about using in-memory only files, but ck2cti expects a string instead of a file handle, so that wouldn't work.
I preferred to implement the working directories as attributes of the
CanteraTest
class, instead of a module-level method inutilities
. This required usingsuper().setUpClass()
in a few places wheresetUpClass
was used in a derived class. This requirement is somewhat unfortunate, and could be alleviated by moving the derivedsetUpClass
methods' into asetUp
method, but this would cause thesetUp
method to be run for each test, typically creating a newSolution
for each test. This could be slow, although the mechanisms we're using tend to be small, so the time hit shouldn't matter very much. Feedback is appreciated on this point.