Closed venzen closed 2 years ago
@venzen, this looks awesome. I like the concept of the "adjust" parameter -- great idea. I'll get familiar with the framework by creating several tests over the next few days.
@venzen , I can't seem to get past line 21 in testapp.py that checks for a parent directory named "tests." My Ubuntu-based 20.04 and 21.04 systems are all running python 3.8.10. The value of __file__
at line 21 is just the relative "testapp.py", not the full path, so the test for the parent directory fails. Google says that the value of __file__
always has the full path in python 3.9 and later. Is there an easy fix for python 3.8?
@davidrmiller, I've added some print statements at line 21 to help us debug. Run only the script (without args) and let me know the output you get:
$ python3 testapp.py
Path(__file__) /Users/mbp/git/biosim4.git/tests/testapp.py
str(Path(__file__).parent) /Users/mbp/git/biosim4.git/tests
endswith('tests') True
I suspect that the assert error you're seeing is simply due to the fact that your shell's current working directory is not 'tests'. :)
On my Ubuntu-based systems with python 3.8.10, those three debug lines in testapp.py give me:
Path(__file__) testapp.py
str(Path(__file__).parent) .
endswith('tests') False
this script must be executed from the ./tests directory
OK, I will have to write some conditional code for Python versions <3 .9. I will commit a solution later today.
Could there be a solution that works for all versions? E.g., on my systems, os.getcwd()
returns the full path to the current tests directory.
@davidrmiller It is true that os.getcwd()
resolves the same in all versions of Python. However, I opted for the pathlib
module because it allows us to resolve pathnames and file locations as objects - much easier and versatile than the clumsy strings provided by os
. There are a lot of file operations throughout the script and its libraries.
I've committed a solution that should solve this for all versions of Python >= 3.4. If a user has a version < 3.4 then they are on an OS that probably cannot compile biosim4
anyway.
That works -- Thanks!
A Python script for testing a biosim4 simulation. It also includes some utility functions to manipulate .ini files and simulation parameters.
Files and libs in Tests directory.