Skip to content

Commit

Permalink
[AIRFLOW-6216] Allow pytests to be run without "tests" (#6770)
Browse files Browse the repository at this point in the history
With this change you should be able to simply run `pytest` to run all the tests in the main airflow directory.

This consist of two changes:

* moving pytest.ini to the main airflow directory
* skipping collecting kubernetes tests when ENV != kubernetes
  • Loading branch information
potiuk authored Dec 10, 2019
1 parent da7a353 commit 239d51e
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
!.rat-excludes
!.flake8
!pylintrc
!pytest.ini
!LICENSE
!MANIFEST.in
!NOTICE
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ COPY docs/ ${AIRFLOW_SOURCES}/docs/
COPY tests/ ${AIRFLOW_SOURCES}/tests/
COPY airflow/ ${AIRFLOW_SOURCES}/airflow/
COPY .coveragerc .rat-excludes .flake8 pylintrc LICENSE MANIFEST.in NOTICE CHANGELOG.txt \
.github \
.github pytest.ini \
setup.cfg setup.py \
${AIRFLOW_SOURCES}/

Expand Down
2 changes: 2 additions & 0 deletions tests/pytest.ini → pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ addopts =
--ignore=tests/dags/test_impersonation_subdag.py
--ignore=tests/dags/test_subdag.py
norecursedirs =
.eggs
airflow
tests/dags_with_system_exit
tests/test_utils
tests/dags_corrupted
Expand Down
1 change: 1 addition & 0 deletions scripts/ci/_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ elif [[ ${AIRFLOW_MOUNT_HOST_VOLUMES_FOR_STATIC_CHECKS} == "true" ]]; then
"-v" "${AIRFLOW_SOURCES}/tests:/opt/airflow/tests:cached" \
"-v" "${AIRFLOW_SOURCES}/.flake8:/opt/airflow/.flake8:cached" \
"-v" "${AIRFLOW_SOURCES}/pylintrc:/opt/airflow/pylintrc:cached" \
"-v" "${AIRFLOW_SOURCES}/pytest.ini:/opt/airflow/pytest.ini:cached" \
"-v" "${AIRFLOW_SOURCES}/setup.cfg:/opt/airflow/setup.cfg:cached" \
"-v" "${AIRFLOW_SOURCES}/setup.py:/opt/airflow/setup.py:cached" \
"-v" "${AIRFLOW_SOURCES}/.rat-excludes:/opt/airflow/.rat-excludes:cached" \
Expand Down
1 change: 1 addition & 0 deletions scripts/ci/docker-compose-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ services:
- ../../.inputrc:/root/.inputrc:cached
- ../../.flake8:/opt/airflow/.flake8:cached
- ../../pylintrc:/opt/airflow/pylintrc:cached
- ../../pytest.ini:/opt/airflow/pytest.ini:cached
- ../../.rat-excludes:/opt/airflow/.rat-excludes:cached
- ../../logs:/root/airflow/logs:cached
- ../../tmp:/opt/airflow/tmp:cached
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/test_kubernetes_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
try:
check_call(["/usr/local/bin/kubectl", "get", "pods"])
except Exception as e: # pylint: disable=broad-except
if os.environ.get('KUBERNETES_VERSION'):
if os.environ.get('KUBERNETES_VERSION') and os.environ.get('ENV', 'kubernetes') == 'kubernetes':
raise e
else:
raise unittest.SkipTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
try:
check_call(["/usr/local/bin/kubectl", "get", "pods"])
except Exception as e: # pylint: disable=broad-except
if os.environ.get('KUBERNETES_VERSION'):
if os.environ.get('KUBERNETES_VERSION') and os.environ.get('ENV', 'kubernetes') == 'kubernetes':
raise e
else:
raise unittest.SkipTest(
Expand Down

0 comments on commit 239d51e

Please sign in to comment.