Skip to content

Migrate remaining tests to pytest #29305

Description

@Taragolis

Body

All tests for Apache Airflow are run using pytest. We have about 80 tests modules which still use unittests runner for pytest , initial plan was "convert all unit tests to standard "asserts" semi-automatically, but this will be done later in Airflow 2.0 development phase. That will include setUp/tearDown/context managers and decorators.", see: Writing Unit Tests

Personally I do not have a free time to complete this tasks, if someone would like to work on one (or many) parts of this Task just let us know in comments or create a PR with reference to this Issue.

For keep in track remaining tasks for migration to "native" pytest runner I split it by separate phases

Phase 1: Migration unittests to pytest

  1. Replace unittests by pytest
  2. Replace @parameterized.expand by @pytest.mark.parametrize

Example how it done previously: https://github.com/apache/airflow/pulls?q=is%3Apr+migrate+tests+pytest+is%3Aclosed+

Always

CLI

Other

Providers

Phase 2: Ban unittests runner

It should be done after Phase 1.

This also include remove parametrized package, all features already exists in pytest core, see: How to parametrize fixtures and test functions

Some useful stuff

I use this command to find any remaining usage of unittests.TestCase and parametrized

# All modules which potentially use  unittests.TestCasegrep -rl 'TestCase' ./tests | sort | uniq -c | sort -nr

# All modules which potentially use parameterizedgrep -rl 'from parameterized' ./tests | sort | uniq -c | sort -nr

# List of providers which potentially use  unittests.TestCase grep -rl 'TestCase' tests/providers/ | cut -d"/" -f4 | sort | uniq -c | sort -nr

Committer

  • I acknowledge that I am a maintainer/committer of the Apache Airflow project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuekind:metaHigh-level information important to the communitytype:misc/internalChangelog: Misc changes that should appear in change log

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions