Problem description
I have a huge project where there are a lots of python files. Unfortunately this project is not properly covered by the tests and we are facing problems with... imports :)
My goal is to execute a 'dry run' of all python scripts(without executing them) just to make sure that all modules are properly imported(especially these local modules) and list all invalid scripts where all imports are impossible.
Example
Let me give you 1st example(script1.py):
from NON_EXISTING_local_module import non_existing_class
import time
def test_something():
time.sleep(10)
test_something()
Import of NON_EXISTING_local_module is impossible like it's done normally in Python by ImportError exception(script1.py marked as invalid)
2nd example(script2.py):
from EXSISTING_local_module import existing_class
import time
def test_something():
time.sleep(10)
test_something()
And here I would like to see that everything is fine(no problems with imports) and that the method test_something() is not executed at all(no need to wait 10s)(script2.py marked as valid)
My research
I know that there is an option to execute and get result of it:
python -c 'import module'
but it does not work with local modules
What is more RobotFramework has such option as --dryrun as it's described here: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#dry-run I'm looking for exactly the same solution but for pure python scripts.
Thanks a lot in advance for any hints!