I want to import the functions defined in a file like described in this question into a test (don't ask about why... combination of legacy system and plugin system)
import imp
module = imp.load_source('module', '/path/to/file.py')
module.some_function()
but got NameError: name '<SOME-VARIABLE>' is not defined
.
'<SOME-VARIABLE>'
is not defined in /path/to/file.py
, but in /another/path/to/another/file.py
. Is it possible to monkey patch <SOME-VARIABLE>
it to allow import of the file/module?