Skip to content

Commit

Permalink
Merge pull request #220 from opentargets/tskir-3140-better-dag-import…
Browse files Browse the repository at this point in the history
…-fix

A better way to fix DAG import test
  • Loading branch information
ireneisdoomed authored Nov 3, 2023
2 parents 4f6d496 + 5a63093 commit 2014e48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ exclude = ["dist"]

[tool.pytest.ini_options]
addopts = "-n auto --doctest-modules --cov=src/ --cov-report=xml"
pythonpath = [
".",
"./src/airflow/dags"
]

[[tool.mypy.overrides]]
module = "google.protobuf.duration_pb2"
Expand Down
6 changes: 1 addition & 5 deletions tests/airflow/test_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@


@pytest.fixture(params=["./src/airflow/dags"])
def dag_bag(request, monkeypatch: pytest.MonkeyPatch):
def dag_bag(request):
"""Return a DAG bag for testing."""
# It's important to change directory before importing DAGs, because this is way Airflow works in production: the
# dags/ directory serves as a root (and indeed $PYTHONPATH) for all DAGS contained therein. Using Monkeypatch
# ensures that the other tests are not affected.
monkeypatch.chdir(request.param)
return DagBag(dag_folder=request.param, include_examples=False)


Expand Down

0 comments on commit 2014e48

Please sign in to comment.