def test_module_path_working(tmpdir): """ Test that running a subprocess task works under normal circumstances (without monkeying with PYTHONPATH). """ tmpdir = Path(tmpdir) (tmpdir / "glean").mkdir() with open(tmpdir / "glean" / "__init__.py", "w") as fd: fd.write("\n") (tmpdir / "foo").mkdir() ProcessDispatcher.dispatch(_rmtree, (str(tmpdir / "foo"), )) returncode = ProcessDispatcher._last_process.wait() assert returncode == 0 assert not (tmpdir / "foo").exists()
def test_module_path_change_pythonpath(tmpdir, monkeypatch): """ If PYTHONPATH gets set to a place with a broken installation of Glean, running a subprocess task should still work. """ tmpdir = Path(tmpdir) (tmpdir / "glean").mkdir() with open(tmpdir / "glean" / "__init__.py", "w") as fd: fd.write("\n") (tmpdir / "foo").mkdir() monkeypatch.setenv("PYTHONPATH", str(tmpdir)) ProcessDispatcher.dispatch(_rmtree, (str(tmpdir), )) returncode = ProcessDispatcher._last_process.wait() assert returncode == 0 assert not (tmpdir / "foo").exists()