Commit 62489782 authored by Yueh-Shun Li's avatar Yueh-Shun Li
Browse files

treewide: modernize Python package pytest flags

Use `(enabled|disabled)(TestPaths|TestMarks|Tests)` and `pytestFlags`
instead of the `__structuredAttrs`-incompatible `pytestFlagsArray`.
parent 7bca6ea9
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -79,11 +79,14 @@ python3Packages.buildPythonApplication {
    pytestCheckHook
  ];

  pytestFlagsArray = [
    # fails on ofborg because of lack of cpu vendor information
    "--deselect=tests/controller/gns3vm/test_virtualbox_gns3_vm.py::test_cpu_vendor_id"
  pytestFlags = [
    # Rerun failed tests up to three times (flaky tests)
    "--reruns 3"
    "--reruns=3"
  ];

  disabledTestPaths = [
    # fails on ofborg because of lack of cpu vendor information
    "tests/controller/gns3vm/test_virtualbox_gns3_vm.py::test_cpu_vendor_id"
  ];

  passthru.tests = {
+6 −4
Original line number Diff line number Diff line
@@ -105,11 +105,13 @@ python3.pkgs.buildPythonApplication rec {
    export PATH="$PATH:$out/bin:${lib.makeBinPath [ git ]}"
  '';

  pytestFlagsArray = [
    "tests"
  pytestFlags = [
    # Disable warnings
    "-W"
    "ignore::DeprecationWarning"
    "-Wignore::DeprecationWarning"
  ];

  enabledTestPaths = [
    "tests"
  ];

  disabledTestPaths = [
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ python3.pkgs.buildPythonApplication rec {
  ];

  # errbot-backend-slackv3 has not been packaged
  pytestFlagsArray = [ "--ignore=tests/backend_tests/slack_test.py" ];
  disabledTestPaths = [ "tests/backend_tests/slack_test.py" ];

  disabledTests = [
    # require networking
+4 −4
Original line number Diff line number Diff line
@@ -36,13 +36,13 @@ python3Packages.buildPythonApplication {
    "test_init"
  ];

  pytestFlagsArray = [
  disabledTestPaths = [
    # requires network access
    "--ignore=test/test_results.py"
    "--ignore=test/test_downloader.py"
    "test/test_results.py"
    "test/test_downloader.py"

    # incompatible with pytestCheckHook
    "--ignore=test/test_ytdl.py"
    "test/test_ytdl.py"
  ];

  pythonImportsCheck = [ "gallery_dl" ];
+24 −28
Original line number Diff line number Diff line
@@ -72,34 +72,6 @@ python3Packages.buildPythonApplication rec {

  versionCheckProgramArg = "--version";

  pytestFlagsArray =
    [
      # AssertionError on the version metadata
      # https://github.com/pypa/hatch/issues/1877
      "--deselect=tests/backend/metadata/test_spec.py::TestCoreMetadataV21::test_all"
      "--deselect=tests/backend/metadata/test_spec.py::TestCoreMetadataV21::test_license_expression"
      "--deselect=tests/backend/metadata/test_spec.py::TestCoreMetadataV22::test_all"
      "--deselect=tests/backend/metadata/test_spec.py::TestCoreMetadataV22::test_license_expression"
      "--deselect=tests/backend/metadata/test_spec.py::TestCoreMetadataV23::test_all"
      "--deselect=tests/backend/metadata/test_spec.py::TestCoreMetadataV23::test_license_expression"
      "--deselect=tests/backend/metadata/test_spec.py::TestCoreMetadataV23::test_license_files"
      "--deselect=tests/backend/metadata/test_spec.py::TestProjectMetadataFromCoreMetadata::test_license_files"
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      # Dependency/versioning errors in the CLI tests, only seem to show up on Darwin
      # https://github.com/pypa/hatch/issues/1893
      "--deselect=tests/cli/env/test_create.py::test_sync_dependencies_pip"
      "--deselect=tests/cli/env/test_create.py::test_sync_dependencies_uv"
      "--deselect=tests/cli/project/test_metadata.py::TestBuildDependenciesMissing::test_no_compatibility_check_if_exists"
      "--deselect=tests/cli/run/test_run.py::TestScriptRunner::test_dependencies"
      "--deselect=tests/cli/run/test_run.py::TestScriptRunner::test_dependencies_from_tool_config"
      "--deselect=tests/cli/run/test_run.py::test_dependency_hash_checking"
      "--deselect=tests/cli/run/test_run.py::test_sync_dependencies"
      "--deselect=tests/cli/run/test_run.py::test_sync_project_dependencies"
      "--deselect=tests/cli/run/test_run.py::test_sync_project_features"
      "--deselect=tests/cli/version/test_version.py::test_no_compatibility_check_if_exists"
    ];

  disabledTests =
    [
      # AssertionError: assert (1980, 1, 2, 0, 0, 0) == (2020, 2, 2, 0, 0, 0)
@@ -157,6 +129,17 @@ python3Packages.buildPythonApplication rec {
      # https://github.com/pypa/hatch/issues/1850
      "tests/backend/licenses/test_parse.py"
      "tests/backend/licenses/test_supported.py"

      # AssertionError on the version metadata
      # https://github.com/pypa/hatch/issues/1877
      "tests/backend/metadata/test_spec.py::TestCoreMetadataV21::test_all"
      "tests/backend/metadata/test_spec.py::TestCoreMetadataV21::test_license_expression"
      "tests/backend/metadata/test_spec.py::TestCoreMetadataV22::test_all"
      "tests/backend/metadata/test_spec.py::TestCoreMetadataV22::test_license_expression"
      "tests/backend/metadata/test_spec.py::TestCoreMetadataV23::test_all"
      "tests/backend/metadata/test_spec.py::TestCoreMetadataV23::test_license_expression"
      "tests/backend/metadata/test_spec.py::TestCoreMetadataV23::test_license_files"
      "tests/backend/metadata/test_spec.py::TestProjectMetadataFromCoreMetadata::test_license_files"
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      # AssertionError: assert [call('test h...2p32/bin/sh')] == [call('test h..., shell=True)]
@@ -165,6 +148,19 @@ python3Packages.buildPythonApplication rec {
      # != call('test hatch-test.py3.10', shell=True)
      "tests/cli/fmt/test_fmt.py"
      "tests/cli/test/test_test.py"

      # Dependency/versioning errors in the CLI tests, only seem to show up on Darwin
      # https://github.com/pypa/hatch/issues/1893
      "tests/cli/env/test_create.py::test_sync_dependencies_pip"
      "tests/cli/env/test_create.py::test_sync_dependencies_uv"
      "tests/cli/project/test_metadata.py::TestBuildDependenciesMissing::test_no_compatibility_check_if_exists"
      "tests/cli/run/test_run.py::TestScriptRunner::test_dependencies"
      "tests/cli/run/test_run.py::TestScriptRunner::test_dependencies_from_tool_config"
      "tests/cli/run/test_run.py::test_dependency_hash_checking"
      "tests/cli/run/test_run.py::test_sync_dependencies"
      "tests/cli/run/test_run.py::test_sync_project_dependencies"
      "tests/cli/run/test_run.py::test_sync_project_features"
      "tests/cli/version/test_version.py::test_no_compatibility_check_if_exists"
    ];

  passthru = {
Loading