the start_here() call starts the VM and makes sure orekit-data is deployed
I am not seeing the print statement executed anywhere even with the -s argument but that does not necessarily imply the script was not run. My tests fail as if the VM is not running, do you think this is due to the script not actually being executed or the VM not staying up after teh script runs? In general am I on the right track?
Thank you in advance.
Edit: The script appears to be running based on console outputs but the VM does not appear to be up when an actual test starts executing.
Edit 2: Not sure what the pitfalls of this may be in the future but I was able to make it work (at least locally, haven’t tried CI/CD) by init’ing the VM and setting up the orekit data directory inside of test/_init_.py
Using a session-scoped fixture with autouse is the right way to go (maybe there are others I don’t know of though), I don’t know why it didn’t work for you. And I also don’t know why setting up the orekit data directory inside of test/_init_.py fixed the issue, normally __init__.py files are not needed by pytest: Good Integration Practices - pytest documentation . Maybe it’s a consistency issue between your repository directory structure and your pytest setup.
Here’s for instance how we managed it in the ephemerista project (works both locally and in CI/CD):
I have a theory on the issue. My tests themselves have Orekit imports, mostly for type hinting but some other things too. I bet if the tests only had imports from my src project which has Orekit imports it could work.
Do people typically have orekit startup in their src init? I’ve mostly been doing one off scripts that start it in the script itself, this is my first attempt at a proper library that leverages Orekit.
Indeed this is very likely to be the cause of the error.
To my knowledge, with the new jpype wrapper it is not possible for the Python interpreter to load the java classes before the JVM is started, unlike with the JCC python wrapper where java classes were defined at compile time. Autocompletion and typing are possible with the jpype wrapper thanks to .pyi stubs, but these stubs cannot be used by the python interpreter.
So to avoid import errors the solution I use is to import java classes in the middle of your code just before using them, as we did for instance in the ephemerista project
Another solution could be starting the JVM at the top of each file you import, or fiddling with the python import system to start the JVM before all other imports.