I need to extend python code that has a lot of hard-coded paths
In order not to damage everything, I want to create unit tests for the code before my modifications: it will run tests without regression with my new code (which will not have hard-coded paths)
But because of the hard coded system path, I will run my test inside the chroot tree (I do not want to pollute the system directory)
My problem is that I want to configure chroot only for the test, and this can be done with os.chroot only with root privileges (and I do not want to run test scripts with root privileges)
Actually, I just need a fake tree pointer, so when the code that open('/etc/resolv.conf)retrieves the fake resolv.conf file, not my system,
I obviously do not want to replace myself with a hard-coded path in the code, because this will not be a real regression test
Do you have any ideas how to achieve this?
thank
Please note that all access to the path is readable using custom accout
Louis source
share