-
-
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
Make cython tests portable #376
Make cython tests portable #376
Conversation
Rather than changing to the work directory, ensure all input/output files come from the the in-package test/data directory. This makes the Cython test suite standalone and the tests can be run using unittest as: python -m unittest -v cantera.test
c673293
to
c586feb
Compare
Funny story: I just wrote the same thing yesterday, but hadn't gotten around to pushing it to Github yet. Oh well. |
Ha I was wondering if I should make a post on the Group about this. Oh well, it only took me a few hours today to figure it all out. Actually, I made #375 as I was trying to debug this PR. |
@speth If you don't have any code comments, I think this is good to merge |
p = self.get_test_data_directory() | ||
convertMech(pjoin(p, 'gri30.inp'), | ||
transportFile=pjoin(p, 'gri30_tran.dat'), | ||
outName=pjoin(p, 'gri30_test.cti'), quiet=True) |
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.
By setting the output name like this, you put the output file into the test/data
directory which (a) pollutes that directory and (b) won't work if that directory isn't writable, e.g. if Cantera is installed as an Ubuntu package.
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.
Good point. I was trying to avoid spraying random output files all over the user's file system. Would it be better to use a temporary directory in the OS's temp storage?
You can avoid introducing duplicate copies of input files by adding the following to for f in ['inputs/h2o2.inp', 'inputs/gri30.inp', 'transport/gri30_tran.dat']:
build(localenv.Install('#interfaces/cython/cantera/test/data/', '#data/'+f)) I pushed my implementation of this to https://github.com/speth/cantera/tree/python-testsuite if you want to compare approaches and see if there are ideas from each that we should use. |
@speth Thanks for the comments. I'll work on this over the weekend and push a new PR. |
Closing in favor of #381 |
Makes the Cython test suite portable by removing relative file references and ensuring all input files are in the in-package
test/data
directory. This enables running the entire test suite out-of-build directory, particularly in the conda package.