Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix remaining PT012 pytest checks: pytest-raises-with-multiple-statements #38270

Closed
73 tasks done
Taragolis opened this issue Mar 18, 2024 · 2 comments
Closed
73 tasks done
Labels
area:providers good first issue kind:meta High-level information important to the community

Comments

@Taragolis
Copy link
Contributor

Taragolis commented Mar 18, 2024

Body

Follow-up task for #38219

We enable this rule for avoid accidentally misses some asserts into the pytest.raises() blocks

Easy way to find all linting problem into the module

  1. Remove corresponding line to particular module into the pyproject.toml in [tool.ruff.lint.per-file-ignores]
  2. Run ruff via pre-commit hook
  3. Run tests locally
pre-commit run ruff --all-files

Run 'ruff' for extremely fast Python linting.............................Failed
- hook id: ruff
- exit code: 1

tests/providers/amazon/aws/hooks/test_base_aws.py:1126:5: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/hooks/test_datasync.py:410:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/hooks/test_eks.py:792:13: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/hooks/test_redshift_data.py:80:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/hooks/test_s3.py:495:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/operators/test_emr_serverless.py:435:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/operators/test_redshift_data.py:300:9: PT012 `pytest.raises()` block should contain a single simple statement
Found 7 errors.
tests/providers/amazon/aws/sensors/test_glacier.py:91:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/sensors/test_glue.py:129:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/sensors/test_lambda_function.py:100:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/system/utils/test_helpers.py:88:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/system/utils/test_helpers.py:125:13: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/transfers/test_redshift_to_s3.py:377:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/triggers/test_ecs.py:55:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/triggers/test_ecs.py:74:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/waiters/test_neptune.py:56:9: PT012 `pytest.raises()` block should contain a single simple statement
tests/providers/amazon/aws/waiters/test_neptune.py:77:9: PT012 `pytest.raises()` block should contain a single simple statement
Found 10 errors.

Tip

Feel free to ask a suggestion/helps in slack channels #contributors or #new-contributors

Note

There is no problem to mark specific case which cannot be easily resolved by add # noqa: PT012 reason why it should be skiped from check

Warning

There is a chance to found a regression into the Providers Code Base, so better fix it separately of other changes. E.g fix regression in code base and adopt the test by the separate PR

Regular Unit Tests

Provider amazon

  • tests/providers/amazon/aws/hooks/test_base_aws.py
  • tests/providers/amazon/aws/hooks/test_datasync.py
  • tests/providers/amazon/aws/hooks/test_eks.py
  • tests/providers/amazon/aws/hooks/test_redshift_data.py
  • tests/providers/amazon/aws/hooks/test_s3.py
  • tests/providers/amazon/aws/operators/test_emr_serverless.py
  • tests/providers/amazon/aws/operators/test_redshift_data.py
  • tests/providers/amazon/aws/sensors/test_glacier.py
  • tests/providers/amazon/aws/sensors/test_glue.py
  • tests/providers/amazon/aws/sensors/test_lambda_function.py
  • tests/providers/amazon/aws/system/utils/test_helpers.py
  • tests/providers/amazon/aws/transfers/test_redshift_to_s3.py
  • tests/providers/amazon/aws/triggers/test_ecs.py
  • tests/providers/amazon/aws/waiters/test_neptune.py

Provider apache.beam

  • tests/providers/apache/beam/hooks/test_beam.py

Provider apache.hive

  • tests/providers/apache/hive/hooks/test_hive.py
  • tests/providers/apache/hive/sensors/test_named_hive_partition.py

Provider apache.spark

  • tests/providers/apache/spark/hooks/test_spark_sql.py

Provider celery

  • tests/providers/celery/sensors/test_celery_queue.py

Provider cncf.kubernetes

  • tests/providers/cncf/kubernetes/executors/test_kubernetes_executor.py
  • tests/providers/cncf/kubernetes/hooks/test_kubernetes.py
  • tests/providers/cncf/kubernetes/operators/test_pod.py
  • tests/providers/cncf/kubernetes/utils/test_k8s_resource_iterator.py
  • tests/providers/cncf/kubernetes/utils/test_pod_manager.py

Provider common.sql

  • tests/providers/common/sql/operators/test_sql.py

Provider databricks

  • tests/providers/databricks/hooks/test_databricks.py
  • tests/providers/databricks/operators/test_databricks.py
  • tests/providers/databricks/operators/test_databricks_repos.py
  • tests/providers/databricks/sensors/test_databricks_partition.py

Provider datadog

  • tests/providers/datadog/sensors/test_datadog.py

Provider dbt

  • tests/providers/dbt/cloud/operators/test_dbt.py

Provider fab

  • tests/providers/fab/auth_manager/cli_commands/test_user_command.py

Provider ftp

  • tests/providers/ftp/operators/test_ftp.py

Provider google

  • tests/providers/google/cloud/hooks/test_bigquery.py
  • tests/providers/google/cloud/hooks/test_cloud_storage_transfer_service.py
  • tests/providers/google/cloud/hooks/test_dataflow.py
  • tests/providers/google/cloud/hooks/test_dataprep.py
  • tests/providers/google/cloud/hooks/test_kubernetes_engine.py
  • tests/providers/google/cloud/hooks/test_pubsub.py
  • tests/providers/google/cloud/operators/test_bigtable.py
  • tests/providers/google/cloud/operators/test_cloud_sql.py
  • tests/providers/google/cloud/operators/test_cloud_storage_transfer_service.py
  • tests/providers/google/cloud/operators/test_compute.py
  • tests/providers/google/cloud/operators/test_datafusion.py
  • tests/providers/google/cloud/operators/test_dataproc.py
  • tests/providers/google/cloud/operators/test_functions.py
  • tests/providers/google/cloud/operators/test_kubernetes_engine.py
  • tests/providers/google/cloud/operators/test_mlengine.py
  • tests/providers/google/cloud/operators/test_spanner.py
  • tests/providers/google/cloud/sensors/test_datafusion.py
  • tests/providers/google/cloud/sensors/test_dataproc.py
  • tests/providers/google/cloud/sensors/test_gcs.py
  • tests/providers/google/cloud/sensors/test_pubsub.py
  • tests/providers/google/cloud/transfers/test_gcs_to_bigquery.py
  • tests/providers/google/cloud/utils/test_credentials_provider.py
  • tests/providers/google/common/hooks/test_base_google.py

Provider jenkins

  • tests/providers/jenkins/sensors/test_jenkins.py

Provider microsoft.azure

  • tests/providers/microsoft/azure/hooks/test_data_factory.py
  • tests/providers/microsoft/azure/hooks/test_wasb.py

Provider microsoft.psrp

  • tests/providers/microsoft/psrp/hooks/test_psrp.py

Provider openai

  • tests/providers/openai/operators/test_openai.py

Provider oracle

  • tests/providers/oracle/hooks/test_oracle.py

Provider papermill

  • tests/providers/papermill/operators/test_papermill.py

Provider sftp

  • tests/providers/sftp/hooks/test_sftp.py
  • tests/providers/sftp/operators/test_sftp.py
  • tests/providers/sftp/sensors/test_sftp.py
  • tests/providers/sftp/triggers/test_sftp.py

Provider ssh

  • tests/providers/ssh/hooks/test_ssh.py
  • tests/providers/ssh/operators/test_ssh.py

Provider telegram

  • tests/providers/telegram/hooks/test_telegram.py
  • tests/providers/telegram/operators/test_telegram.py

K8S Tests

For more detail have a look Kubernetes tests into the contributors documentation

"kubernetes_tests/*" = ["D", "TID253", "S101", "PT012"]

  • kubernetes_tests/test_kubernetes_pod_operator.py

Committer

  • I acknowledge that I am a maintainer/committer of the Apache Airflow project.
@shahar1
Copy link
Collaborator

shahar1 commented Apr 3, 2024

And we're done :)
Good job everyone!

@potiuk potiuk closed this as completed Apr 3, 2024
@potiuk
Copy link
Member

potiuk commented Apr 3, 2024

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers good first issue kind:meta High-level information important to the community
Projects
None yet
Development

No branches or pull requests

3 participants