Hi,<div><br></div><div>I&#39;m trying to decouple a package from it&#39;s deployed environment. In order to make it testable. For this I need to change some hardcoded paths currently defined at module level things in the form </div>
<div><br></div><div>PATH_TO_SCRIPTS = &#39;/var/lib/..../&#39;</div><div><br></div><div>in production those files must be present and the build process takes care of that. However in development and testing I will like to have those paths be different.</div>
<div><br></div><div>I could override those at import time but it will mean having to override the variable on each test module. </div><div><br></div><div>therefore I think a better solution will be to pollute the package a little with a flag to check this.</div>
<div><br></div><div>I&#39;m thinking of something like</div><div><br></div><div>PATH_TO_SCRIPTS = &#39;/this/value/will/never/be&#39;</div><div><br></div><div>if &lt;running in testing&gt;:</div><div>    PATH_TO_SCRIPTS = &#39;../some_checkout&#39;</div>
<div>else:</div><div>    PATH_TO_SCRIPTS = &#39;/var/lib/...../&#39;</div><div><br></div><div>this will be at my module.__init__.py which means everything should work with either path specified as long as they contain some scripts.</div>
<div><br></div><div>Bonus points if someone could point out how to add a third flag to differentiate from development and testing.</div><div><br></div><div>BTW this is with unittest2 although I think the solution should be valid for all other testing tools. </div>