예제 #1
0
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()
예제 #2
0
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()