with TemporaryDirectory() as d:
        venv.create(d, with_pip=False)
        yield Path(d) / "bin" / "python"
@pytest.fixture()
def venv_python_with_dill():
    with TemporaryDirectory() as d:
        venv.create(d, with_pip=True)
        python_path = Path(d) / "bin" / "python"
        subprocess.call([python_path, "-m", "pip", "install", "dill"])
        yield python_path
class TestExternalPythonDecorator:
    def test_with_dill_works(self, dag_maker, venv_python_with_dill):
        @task.external_python(python=venv_python_with_dill, use_dill=True)
        def f():
            """Import dill to double-check it is installed ."""
            import dill  
        with dag_maker():
            ret = f()
        ret.operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
    def test_no_dill_installed_raises_exception_when_use_dill(self, dag_maker, venv_python):
        @task.external_python(python=venv_python, use_dill=True)
        def f():
            pass
        with dag_maker():
            ret = f()
        with pytest.raises(CalledProcessError):
            ret.operator.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
    def test_exception_raises_error(self, dag_maker, venv_python):
        @task.external_python(python=venv_python)
        def f():