def xdg_data_home(request): """A fixure that creates a temporary $XDG_DATA_HOME directory.""" d = tempfile.mkdtemp() with ENV.swap(XDG_DATA_HOME=d): with environ.context(): yield d shutil.rmtree(d)
def test_detached_call(): with ENV.swap(FIXIE_DETACHED_CALL='test'), tempfile.NamedTemporaryFile( 'w+t') as f: child_pid = detached_call(['env'], stdout=f) status = waitpid(child_pid, timeout=10.0) f.seek(0) s = f.read() assert status assert os.getpid() != child_pid assert 'FIXIE_DETACHED_CALL=test' in s
def xdg(request): """A fixure that creates a temporary XDG base directory and sets $XDG_DATA_HOME={xdg-base}/share and $XDG_CONFIG_HOME={xdg-base}/config. """ d = tempfile.mkdtemp() data = os.path.join(d, 'share') conf = os.path.join(d, 'config') with ENV.swap(XDG_DATA_HOME=data, XDG_CONFIG_HOME=conf): with environ.context(): yield d shutil.rmtree(d)