From 38d8547dfe33e3340428ac1edfbaa315f6a9c5e7 Mon Sep 17 00:00:00 2001 From: Mathieu Kniewallner Date: Sat, 26 Oct 2024 16:42:34 +0200 Subject: [PATCH] test(functional): use `arrow` instead of `tomli` `tomli` is usually conditionally imported based on Python version, so this breaks tests on specific versions. --- tests/fixtures/example_project/pyproject.toml | 2 +- .../example_project/src/notebook.ipynb | 2 +- tests/fixtures/pep_621_project/pyproject.toml | 2 +- .../pep_621_project/src/notebook.ipynb | 2 +- .../project_using_namespace/pyproject.toml | 2 +- .../project_with_gitignore/pyproject.toml | 2 +- .../project_with_gitignore/src/notebook.ipynb | 2 +- .../pyproject.toml | 2 +- .../fixtures/project_with_pdm/pyproject.toml | 2 +- .../project_with_pdm/src/notebook.ipynb | 2 +- .../project_with_poetry/pyproject.toml | 2 +- .../project_with_poetry/src/notebook.ipynb | 2 +- .../a_sub_directory/pyproject.toml | 2 +- .../project_with_src_directory/notebook.ipynb | 2 +- .../src/notebook.ipynb | 2 +- .../requirements.txt | 2 +- .../src/notebook.ipynb | 2 +- .../requirements.txt | 2 +- .../src/notebook.ipynb | 2 +- .../project_with_src_directory/pyproject.toml | 2 +- .../project_with_src_directory/notebook.ipynb | 2 +- tests/fixtures/project_with_uv/pyproject.toml | 2 +- .../project_with_uv/src/notebook.ipynb | 2 +- tests/functional/cli/test_cli.py | 36 +++++++++---------- .../test_cli_multiple_source_directories.py | 4 +-- tests/functional/cli/test_cli_namespace.py | 8 ++--- .../cli/test_cli_requirements_in.py | 8 ++--- 27 files changed, 51 insertions(+), 51 deletions(-) diff --git a/tests/fixtures/example_project/pyproject.toml b/tests/fixtures/example_project/pyproject.toml index e1852c73f..b053354fb 100644 --- a/tests/fixtures/example_project/pyproject.toml +++ b/tests/fixtures/example_project/pyproject.toml @@ -6,11 +6,11 @@ authors = [] [tool.poetry.dependencies] python = ">=3.9" +arrow = "1.3.0" click = "8.1.7" isort = "5.13.2" pkginfo = "1.11.2" requests = "2.32.3" -tomli = "2.0.2" urllib3 = "2.2.3" [tool.poetry.dev-dependencies] diff --git a/tests/fixtures/example_project/src/notebook.ipynb b/tests/fixtures/example_project/src/notebook.ipynb index 326bff64f..c73e2597b 100644 --- a/tests/fixtures/example_project/src/notebook.ipynb +++ b/tests/fixtures/example_project/src/notebook.ipynb @@ -12,7 +12,7 @@ "%%timeit\n", "import click\n", "from urllib3 import contrib\n", - "import tomli\n", + "import arrow\n", "1 +\\\n", " 2" ] diff --git a/tests/fixtures/pep_621_project/pyproject.toml b/tests/fixtures/pep_621_project/pyproject.toml index 3f17b329e..eea518569 100644 --- a/tests/fixtures/pep_621_project/pyproject.toml +++ b/tests/fixtures/pep_621_project/pyproject.toml @@ -3,12 +3,12 @@ name = "foo" version = "0.0.1" requires-python = ">=3.9" dependencies = [ + "arrow==1.3.0", "asyncio==3.4.3", "click==8.1.7", "isort==5.13.2", "pkginfo==1.11.2", "requests==2.32.3", - "tomli==2.0.2", "urllib3==2.2.3", ] diff --git a/tests/fixtures/pep_621_project/src/notebook.ipynb b/tests/fixtures/pep_621_project/src/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/pep_621_project/src/notebook.ipynb +++ b/tests/fixtures/pep_621_project/src/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/fixtures/project_using_namespace/pyproject.toml b/tests/fixtures/project_using_namespace/pyproject.toml index e549f3524..e5804aed9 100644 --- a/tests/fixtures/project_using_namespace/pyproject.toml +++ b/tests/fixtures/project_using_namespace/pyproject.toml @@ -2,7 +2,7 @@ name = "foo" version = "0.0.1" requires-python = ">=3.9" -dependencies = ["tomli==2.0.2"] +dependencies = ["arrow==1.3.0"] [project.optional-dependencies] dev = ["flake8==7.1.1"] diff --git a/tests/fixtures/project_with_gitignore/pyproject.toml b/tests/fixtures/project_with_gitignore/pyproject.toml index 4018ab074..a53d67aac 100644 --- a/tests/fixtures/project_with_gitignore/pyproject.toml +++ b/tests/fixtures/project_with_gitignore/pyproject.toml @@ -3,11 +3,11 @@ name = "foo" version = "0.0.1" requires-python = ">=3.9" dependencies = [ + "arrow==1.3.0", "click==8.1.7", "isort==5.13.2", "pkginfo==1.11.2", "requests==2.32.3", - "tomli==2.0.2", "urllib3==2.2.3", ] diff --git a/tests/fixtures/project_with_gitignore/src/notebook.ipynb b/tests/fixtures/project_with_gitignore/src/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/project_with_gitignore/src/notebook.ipynb +++ b/tests/fixtures/project_with_gitignore/src/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/fixtures/project_with_multiple_source_directories/pyproject.toml b/tests/fixtures/project_with_multiple_source_directories/pyproject.toml index 5d65f5d1d..e8e98eb7e 100644 --- a/tests/fixtures/project_with_multiple_source_directories/pyproject.toml +++ b/tests/fixtures/project_with_multiple_source_directories/pyproject.toml @@ -2,7 +2,7 @@ name = "foo" version = "0.0.1" requires-python = ">=3.9" -dependencies = ["tomli==2.0.2"] +dependencies = ["arrow==1.3.0"] [build-system] requires = ["setuptools>=61.0.0"] diff --git a/tests/fixtures/project_with_pdm/pyproject.toml b/tests/fixtures/project_with_pdm/pyproject.toml index 40fc71663..7439456e9 100644 --- a/tests/fixtures/project_with_pdm/pyproject.toml +++ b/tests/fixtures/project_with_pdm/pyproject.toml @@ -3,8 +3,8 @@ name = "foo" version = "0.0.1" requires-python = ">=3.9" dependencies = [ + "arrow==1.3.0", "pkginfo==1.11.2", - "tomli==2.0.2", "urllib3==2.2.3", ] diff --git a/tests/fixtures/project_with_pdm/src/notebook.ipynb b/tests/fixtures/project_with_pdm/src/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/project_with_pdm/src/notebook.ipynb +++ b/tests/fixtures/project_with_pdm/src/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/fixtures/project_with_poetry/pyproject.toml b/tests/fixtures/project_with_poetry/pyproject.toml index 677630bde..4fe45d7b1 100644 --- a/tests/fixtures/project_with_poetry/pyproject.toml +++ b/tests/fixtures/project_with_poetry/pyproject.toml @@ -6,8 +6,8 @@ authors = [] [tool.poetry.dependencies] python = ">=3.9" +arrow = "1.3.0" pkginfo = "1.11.2" -tomli = "2.0.2" urllib3 = "2.2.3" click = { version = "8.1.7", optional = true } diff --git a/tests/fixtures/project_with_poetry/src/notebook.ipynb b/tests/fixtures/project_with_poetry/src/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/project_with_poetry/src/notebook.ipynb +++ b/tests/fixtures/project_with_poetry/src/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/fixtures/project_with_pyproject_different_directory/a_sub_directory/pyproject.toml b/tests/fixtures/project_with_pyproject_different_directory/a_sub_directory/pyproject.toml index 4018ab074..a53d67aac 100644 --- a/tests/fixtures/project_with_pyproject_different_directory/a_sub_directory/pyproject.toml +++ b/tests/fixtures/project_with_pyproject_different_directory/a_sub_directory/pyproject.toml @@ -3,11 +3,11 @@ name = "foo" version = "0.0.1" requires-python = ">=3.9" dependencies = [ + "arrow==1.3.0", "click==8.1.7", "isort==5.13.2", "pkginfo==1.11.2", "requests==2.32.3", - "tomli==2.0.2", "urllib3==2.2.3", ] diff --git a/tests/fixtures/project_with_pyproject_different_directory/src/project_with_src_directory/notebook.ipynb b/tests/fixtures/project_with_pyproject_different_directory/src/project_with_src_directory/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/project_with_pyproject_different_directory/src/project_with_src_directory/notebook.ipynb +++ b/tests/fixtures/project_with_pyproject_different_directory/src/project_with_src_directory/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/fixtures/project_with_requirements_in/src/notebook.ipynb b/tests/fixtures/project_with_requirements_in/src/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/project_with_requirements_in/src/notebook.ipynb +++ b/tests/fixtures/project_with_requirements_in/src/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/fixtures/project_with_requirements_txt/requirements.txt b/tests/fixtures/project_with_requirements_txt/requirements.txt index c9d5b1168..c2fd1efe4 100644 --- a/tests/fixtures/project_with_requirements_txt/requirements.txt +++ b/tests/fixtures/project_with_requirements_txt/requirements.txt @@ -1,5 +1,5 @@ +arrow==1.3.0 click==8.1.7 isort==5.13.2 pkginfo==1.11.2 requests==2.32.3 -tomli==2.0.2 diff --git a/tests/fixtures/project_with_requirements_txt/src/notebook.ipynb b/tests/fixtures/project_with_requirements_txt/src/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/project_with_requirements_txt/src/notebook.ipynb +++ b/tests/fixtures/project_with_requirements_txt/src/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/fixtures/project_with_setuptools_dynamic_dependencies/requirements.txt b/tests/fixtures/project_with_setuptools_dynamic_dependencies/requirements.txt index 2317fc1d2..6826b82c9 100644 --- a/tests/fixtures/project_with_setuptools_dynamic_dependencies/requirements.txt +++ b/tests/fixtures/project_with_setuptools_dynamic_dependencies/requirements.txt @@ -1,3 +1,3 @@ +arrow==1.3.0 pkginfo==1.11.1 requests==2.32.3 -tomli==2.0.2 diff --git a/tests/fixtures/project_with_setuptools_dynamic_dependencies/src/notebook.ipynb b/tests/fixtures/project_with_setuptools_dynamic_dependencies/src/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/project_with_setuptools_dynamic_dependencies/src/notebook.ipynb +++ b/tests/fixtures/project_with_setuptools_dynamic_dependencies/src/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/fixtures/project_with_src_directory/pyproject.toml b/tests/fixtures/project_with_src_directory/pyproject.toml index 4018ab074..a53d67aac 100644 --- a/tests/fixtures/project_with_src_directory/pyproject.toml +++ b/tests/fixtures/project_with_src_directory/pyproject.toml @@ -3,11 +3,11 @@ name = "foo" version = "0.0.1" requires-python = ">=3.9" dependencies = [ + "arrow==1.3.0", "click==8.1.7", "isort==5.13.2", "pkginfo==1.11.2", "requests==2.32.3", - "tomli==2.0.2", "urllib3==2.2.3", ] diff --git a/tests/fixtures/project_with_src_directory/src/project_with_src_directory/notebook.ipynb b/tests/fixtures/project_with_src_directory/src/project_with_src_directory/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/project_with_src_directory/src/project_with_src_directory/notebook.ipynb +++ b/tests/fixtures/project_with_src_directory/src/project_with_src_directory/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/fixtures/project_with_uv/pyproject.toml b/tests/fixtures/project_with_uv/pyproject.toml index 3cd1bcd7d..456104e98 100644 --- a/tests/fixtures/project_with_uv/pyproject.toml +++ b/tests/fixtures/project_with_uv/pyproject.toml @@ -3,8 +3,8 @@ name = "foo" version = "0.0.1" requires-python = ">=3.9" dependencies = [ + "arrow==1.3.0", "pkginfo==1.11.2", - "tomli==2.0.2", "urllib3==2.2.3", ] diff --git a/tests/fixtures/project_with_uv/src/notebook.ipynb b/tests/fixtures/project_with_uv/src/notebook.ipynb index 909a5bcd5..42be444d9 100644 --- a/tests/fixtures/project_with_uv/src/notebook.ipynb +++ b/tests/fixtures/project_with_uv/src/notebook.ipynb @@ -9,7 +9,7 @@ "source": [ "import click\n", "from urllib3 import contrib\n", - "import tomli" + "import arrow" ] } ], diff --git a/tests/functional/cli/test_cli.py b/tests/functional/cli/test_cli.py index 60c6f663a..4bd5808c4 100644 --- a/tests/functional/cli/test_cli.py +++ b/tests/functional/cli/test_cli.py @@ -85,9 +85,9 @@ def test_cli_ignore_notebooks(poetry_venv_factory: PoetryVenvFactory) -> None: { "error": { "code": "DEP002", - "message": "'isort' defined as a dependency but not used in the codebase", + "message": "'arrow' defined as a dependency but not used in the codebase", }, - "module": "isort", + "module": "arrow", "location": { "file": str(Path("pyproject.toml")), "line": None, @@ -97,9 +97,9 @@ def test_cli_ignore_notebooks(poetry_venv_factory: PoetryVenvFactory) -> None: { "error": { "code": "DEP002", - "message": "'requests' defined as a dependency but not used in the codebase", + "message": "'isort' defined as a dependency but not used in the codebase", }, - "module": "requests", + "module": "isort", "location": { "file": str(Path("pyproject.toml")), "line": None, @@ -109,9 +109,9 @@ def test_cli_ignore_notebooks(poetry_venv_factory: PoetryVenvFactory) -> None: { "error": { "code": "DEP002", - "message": "'tomli' defined as a dependency but not used in the codebase", + "message": "'requests' defined as a dependency but not used in the codebase", }, - "module": "tomli", + "module": "requests", "location": { "file": str(Path("pyproject.toml")), "line": None, @@ -172,9 +172,9 @@ def test_cli_exclude(poetry_venv_factory: PoetryVenvFactory) -> None: { "error": { "code": "DEP002", - "message": "'isort' defined as a dependency but not used in the codebase", + "message": "'arrow' defined as a dependency but not used in the codebase", }, - "module": "isort", + "module": "arrow", "location": { "file": str(Path("pyproject.toml")), "line": None, @@ -184,9 +184,9 @@ def test_cli_exclude(poetry_venv_factory: PoetryVenvFactory) -> None: { "error": { "code": "DEP002", - "message": "'requests' defined as a dependency but not used in the codebase", + "message": "'isort' defined as a dependency but not used in the codebase", }, - "module": "requests", + "module": "isort", "location": { "file": str(Path("pyproject.toml")), "line": None, @@ -196,9 +196,9 @@ def test_cli_exclude(poetry_venv_factory: PoetryVenvFactory) -> None: { "error": { "code": "DEP002", - "message": "'tomli' defined as a dependency but not used in the codebase", + "message": "'requests' defined as a dependency but not used in the codebase", }, - "module": "tomli", + "module": "requests", "location": { "file": str(Path("pyproject.toml")), "line": None, @@ -243,9 +243,9 @@ def test_cli_extend_exclude(poetry_venv_factory: PoetryVenvFactory) -> None: { "error": { "code": "DEP002", - "message": "'isort' defined as a dependency but not used in the codebase", + "message": "'arrow' defined as a dependency but not used in the codebase", }, - "module": "isort", + "module": "arrow", "location": { "file": str(Path("pyproject.toml")), "line": None, @@ -255,9 +255,9 @@ def test_cli_extend_exclude(poetry_venv_factory: PoetryVenvFactory) -> None: { "error": { "code": "DEP002", - "message": "'requests' defined as a dependency but not used in the codebase", + "message": "'isort' defined as a dependency but not used in the codebase", }, - "module": "requests", + "module": "isort", "location": { "file": str(Path("pyproject.toml")), "line": None, @@ -267,9 +267,9 @@ def test_cli_extend_exclude(poetry_venv_factory: PoetryVenvFactory) -> None: { "error": { "code": "DEP002", - "message": "'tomli' defined as a dependency but not used in the codebase", + "message": "'requests' defined as a dependency but not used in the codebase", }, - "module": "tomli", + "module": "requests", "location": { "file": str(Path("pyproject.toml")), "line": None, diff --git a/tests/functional/cli/test_cli_multiple_source_directories.py b/tests/functional/cli/test_cli_multiple_source_directories.py index 85c499425..de60ad96b 100644 --- a/tests/functional/cli/test_cli_multiple_source_directories.py +++ b/tests/functional/cli/test_cli_multiple_source_directories.py @@ -22,8 +22,8 @@ def test_cli_with_multiple_source_directories(pip_venv_factory: PipVenvFactory) assert result.returncode == 1 assert get_issues_report(Path(issue_report)) == [ { - "error": {"code": "DEP002", "message": "'tomli' defined as a dependency but not used in the codebase"}, - "module": "tomli", + "error": {"code": "DEP002", "message": "'arrow' defined as a dependency but not used in the codebase"}, + "module": "arrow", "location": {"file": str(Path("pyproject.toml")), "line": None, "column": None}, }, { diff --git a/tests/functional/cli/test_cli_namespace.py b/tests/functional/cli/test_cli_namespace.py index 42f01eb62..27494511d 100644 --- a/tests/functional/cli/test_cli_namespace.py +++ b/tests/functional/cli/test_cli_namespace.py @@ -32,8 +32,8 @@ def test_cli_with_namespace(pip_venv_factory: PipVenvFactory) -> None: "location": {"file": str(Path("foo/database/bar.py")), "line": 5, "column": 8}, }, { - "error": {"code": "DEP002", "message": "'tomli' defined as a dependency but not used in the codebase"}, - "module": "tomli", + "error": {"code": "DEP002", "message": "'arrow' defined as a dependency but not used in the codebase"}, + "module": "arrow", "location": {"file": str(Path("pyproject.toml")), "line": None, "column": None}, }, ] @@ -63,8 +63,8 @@ def test_cli_with_namespace_without_experimental_flag(pip_venv_factory: PipVenvF "location": {"file": str(Path("foo/database/bar.py")), "line": 7, "column": 1}, }, { - "error": {"code": "DEP002", "message": "'tomli' defined as a dependency but not used in the codebase"}, - "module": "tomli", + "error": {"code": "DEP002", "message": "'arrow' defined as a dependency but not used in the codebase"}, + "module": "arrow", "location": {"file": str(Path("pyproject.toml")), "line": None, "column": None}, }, ] diff --git a/tests/functional/cli/test_cli_requirements_in.py b/tests/functional/cli/test_cli_requirements_in.py index eb7c79dab..2c6150510 100644 --- a/tests/functional/cli/test_cli_requirements_in.py +++ b/tests/functional/cli/test_cli_requirements_in.py @@ -57,8 +57,8 @@ def test_cli_single_requirements_files(pip_venv_factory: PipVenvFactory) -> None "location": {"file": str(Path("src/main.py")), "line": 7, "column": 8}, }, { - "error": {"code": "DEP001", "message": "'tomli' imported but missing from the dependency definitions"}, - "module": "tomli", + "error": {"code": "DEP001", "message": "'arrow' imported but missing from the dependency definitions"}, + "module": "arrow", "location": {"file": str(Path("src/notebook.ipynb")), "line": 3, "column": 8}, }, ] @@ -104,8 +104,8 @@ def test_cli_multiple_requirements_files(pip_venv_factory: PipVenvFactory) -> No "location": {"file": str(Path("src/main.py")), "line": 7, "column": 8}, }, { - "error": {"code": "DEP001", "message": "'tomli' imported but missing from the dependency definitions"}, - "module": "tomli", + "error": {"code": "DEP001", "message": "'arrow' imported but missing from the dependency definitions"}, + "module": "arrow", "location": {"file": str(Path("src/notebook.ipynb")), "line": 3, "column": 8}, }, ]