From c3e08e48181ef403d63d3de3764407aafb265f5a Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:02:01 +0100 Subject: [PATCH 01/21] Switch from `tox-gh-actions` to `tox-gh` --- .github/workflows/test.yml | 6 +++--- {{cookiecutter.project_slug}}/.github/workflows/tests.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b10842e5..95f1ca22 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,9 +40,9 @@ jobs: cache-dependency-path: pyproject.toml - name: Install dependencies - run: python -m pip install tox tox-gh-actions + run: python -m pip install tox tox-gh - name: Run tests - run: tox + run: tox run env: - OS: ${{ matrix.os }} + TOX_GH_MAJOR_MINOR: ${{ matrix.python-version }} diff --git a/{{cookiecutter.project_slug}}/.github/workflows/tests.yml b/{{cookiecutter.project_slug}}/.github/workflows/tests.yml index 75b38278..ffe309eb 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/tests.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/tests.yml @@ -39,7 +39,7 @@ jobs: cache-dependency-path: pyproject.toml - name: Install dependencies - run: python -m pip install tox tox-gh-actions + run: python -m pip install tox tox-gh - name: Test with tox - run: tox + run: tox run From a2456d7368af8f29590ac91f138bac01071d0443 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:02:23 +0100 Subject: [PATCH 02/21] Switch straightforward `pyproject.toml` --- pyproject.toml | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9ed875de..66163970 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,31 +38,27 @@ spaces_indent_inline_array = 4 trailing_comma_inline_array = true overrides."project.classifiers".inline_arrays = false overrides."tool.coverage.paths.source".inline_arrays = false +overrides."tool.tox.env_run_base.commands".inline_arrays = false [tool.tox] -legacy_tox_ini = """ - [gh-actions] - python = - 3.11: py311 - 3.12: py312 - 3.13: py313 - - [gh-actions:env] - OS = - ubuntu-latest: linux - macos-latest: macos - windows-latest: windows - - [testenv] - skip_install = true - description = - Test package creation - deps = - cookiecutter - pytest - commands = - pytest {posargs} - - [tox] - env_list = py3{11,12,13}-{linux,macos,windows} -""" +env_list = [ + "py311", + "py312", + "py313", +] +env_run_base = {commands = [ + [ + "pytest", + "{posargs}", + ], +], deps = [ + "cookiecutter", + "pytest", +], description="Test package creation", skip_install=true} +gh.python = {"3.11" = [ + "py311", +], "3.12" = [ + "py312", +], "3.13" = [ + "py313", +]} From 0830fd5e0f360af011d75bb9dcab32b4e243cc7d Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:02:45 +0100 Subject: [PATCH 03/21] Switch more complicated `pyproject.toml` --- {{cookiecutter.project_slug}}/pyproject.toml | 62 ++++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 30bea4d6..551115fc 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -111,36 +111,36 @@ spaces_indent_inline_array = 4 trailing_comma_inline_array = true overrides."project.classifiers".inline_arrays = false overrides."tool.coverage.paths.source".inline_arrays = false +overrides."tool.tox.env_run_base.commands".inline_arrays = false [tool.tox] -legacy_tox_ini = """ - [gh-actions] - python = - {%- for python_version in range( - cookiecutter.min_python_version | replace('3.', '') | int, - cookiecutter.max_python_version | replace('3.', '') | int + 1 - ) %} - 3.{{python_version}}: py3{{python_version}} - {%- endfor %} - - [testenv] - commands = - pytest --cov --cov-report=xml - extras = - test - - [testenv:docs] - commands = - mkdocs build --strict - extras = - docs - - [tox] - env_list = - {%- for python_version in range( - cookiecutter.min_python_version | replace('3.', '') | int, - cookiecutter.max_python_version | replace('3.', '') | int + 1 - ) %} - py3{{python_version}} - {%- endfor %} -""" +env_list = [ +{%- for python_version in range( + cookiecutter.min_python_version | replace('3.', '') | int, + cookiecutter.max_python_version | replace('3.', '') | int + 1 +) %} + "py3{{python_version}}" +{%- endfor %} +] +env_run_base = {commands = [ + [ + "pytest", + "--cov", + "--cov-report=xml", + ], +], extras = [ + "test", +]} +{%- for python_version in range( + cookiecutter.min_python_version | replace('3.', '') | int, + cookiecutter.max_python_version | replace('3.', '') | int + 1 +) %} +gh.python."3.{{python_version}}" = ["py3{{python_version}}"] +{%- endfor %} +env.docs = {commands = [ + "mkdocs", + "build", + "--strict", +], extras = [ + "docs", +]} From 5e37c5f94bd613370df22bf50be3b13979301438 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:08:29 +0100 Subject: [PATCH 04/21] Fix linting --- pyproject.toml | 2 +- {{cookiecutter.project_slug}}/pyproject.toml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 66163970..2e03f83c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ env_run_base = {commands = [ ], deps = [ "cookiecutter", "pytest", -], description="Test package creation", skip_install=true} +], description = "Test package creation", skip_install = true} gh.python = {"3.11" = [ "py311", ], "3.12" = [ diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 551115fc..c536ada5 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -131,12 +131,6 @@ env_run_base = {commands = [ ], extras = [ "test", ]} -{%- for python_version in range( - cookiecutter.min_python_version | replace('3.', '') | int, - cookiecutter.max_python_version | replace('3.', '') | int + 1 -) %} -gh.python."3.{{python_version}}" = ["py3{{python_version}}"] -{%- endfor %} env.docs = {commands = [ "mkdocs", "build", @@ -144,3 +138,9 @@ env.docs = {commands = [ ], extras = [ "docs", ]} +{%- for python_version in range( + cookiecutter.min_python_version | replace('3.', '') | int, + cookiecutter.max_python_version | replace('3.', '') | int + 1 +) %} +gh.python."3.{{python_version}}" = ["py3{{python_version}}"] +{%- endfor %} From a2fac2d6af434d3cdcd8b1a973a2051fdb88db29 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:11:26 +0100 Subject: [PATCH 05/21] Forgot comma --- {{cookiecutter.project_slug}}/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index c536ada5..96ad87da 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -119,7 +119,7 @@ env_list = [ cookiecutter.min_python_version | replace('3.', '') | int, cookiecutter.max_python_version | replace('3.', '') | int + 1 ) %} - "py3{{python_version}}" + "py3{{python_version}}", {%- endfor %} ] env_run_base = {commands = [ From d966e98e79f5134ecfb4455c64c5d1329942ac22 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:14:23 +0100 Subject: [PATCH 06/21] Fix `toml-sort` --- {{cookiecutter.project_slug}}/pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index 96ad87da..fdb18b8d 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -112,6 +112,7 @@ trailing_comma_inline_array = true overrides."project.classifiers".inline_arrays = false overrides."tool.coverage.paths.source".inline_arrays = false overrides."tool.tox.env_run_base.commands".inline_arrays = false +overrides."tool.tox.env.docs.commands".inline_arrays = false [tool.tox] env_list = [ From 8bb41304bb68b57949895a015a8eb87508992bf0 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:17:39 +0100 Subject: [PATCH 07/21] Sort overrides --- {{cookiecutter.project_slug}}/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/{{cookiecutter.project_slug}}/pyproject.toml b/{{cookiecutter.project_slug}}/pyproject.toml index fdb18b8d..b49cf0d3 100644 --- a/{{cookiecutter.project_slug}}/pyproject.toml +++ b/{{cookiecutter.project_slug}}/pyproject.toml @@ -111,8 +111,8 @@ spaces_indent_inline_array = 4 trailing_comma_inline_array = true overrides."project.classifiers".inline_arrays = false overrides."tool.coverage.paths.source".inline_arrays = false -overrides."tool.tox.env_run_base.commands".inline_arrays = false overrides."tool.tox.env.docs.commands".inline_arrays = false +overrides."tool.tox.env_run_base.commands".inline_arrays = false [tool.tox] env_list = [ From bcd541ef76d05fbfe5a6ebba4aaa9d818e4debf9 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:28:33 +0100 Subject: [PATCH 08/21] Fix tests with globbing --- tests/test_package_generation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 80534a51..7331cb8f 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -76,6 +76,8 @@ def test_package_generation( pathlib.Path("src/cookiecutter_test/__init__.py"), pathlib.Path("tests"), pathlib.Path("tests/test_dummy.py"), + pathlib.Path("tests/__pycache__"), + pathlib.Path("tests/__pycache__/").glob("test_dummy.cpython-*-pytest-*.pyc"), } actual_files = get_all_files_folders(test_project_dir) From 7758c6a723f5e7e5dbdafeb6d495ec4485495aeb Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:43:54 +0100 Subject: [PATCH 09/21] Try `PurePath` --- tests/test_package_generation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 7331cb8f..876eb88d 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -44,7 +44,7 @@ def test_package_generation( assert test_project_dir.exists() # Check main files and directories inside - expected_files: set[pathlib.Path] = { + expected_files: set[pathlib.Path | pathlib.PurePath] = { pathlib.Path(), pathlib.Path(".git"), pathlib.Path(".github"), @@ -77,7 +77,7 @@ def test_package_generation( pathlib.Path("tests"), pathlib.Path("tests/test_dummy.py"), pathlib.Path("tests/__pycache__"), - pathlib.Path("tests/__pycache__/").glob("test_dummy.cpython-*-pytest-*.pyc"), + pathlib.PurePath("tests/__pycache__/test_dummy.cpython-*-pytest-*.pyc"), } actual_files = get_all_files_folders(test_project_dir) From f57ea8bc354786d1d69314d1930f3946e6a361f3 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 11:45:51 +0100 Subject: [PATCH 10/21] Try `PosixPath` --- tests/test_package_generation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 876eb88d..e381eb6f 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -44,7 +44,7 @@ def test_package_generation( assert test_project_dir.exists() # Check main files and directories inside - expected_files: set[pathlib.Path | pathlib.PurePath] = { + expected_files: set[pathlib.Path] = { pathlib.Path(), pathlib.Path(".git"), pathlib.Path(".github"), @@ -77,7 +77,7 @@ def test_package_generation( pathlib.Path("tests"), pathlib.Path("tests/test_dummy.py"), pathlib.Path("tests/__pycache__"), - pathlib.PurePath("tests/__pycache__/test_dummy.cpython-*-pytest-*.pyc"), + pathlib.PosixPath("tests/__pycache__/test_dummy.cpython-*-pytest-*.pyc"), } actual_files = get_all_files_folders(test_project_dir) From bd6ccedfe62bcd21bae0098278943353df952277 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 12:43:46 +0100 Subject: [PATCH 11/21] Skip `__pycache__` directories --- tests/test_package_generation.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index e381eb6f..735a40f5 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -18,6 +18,10 @@ def get_all_files_folders(root_path: pathlib.Path) -> set[pathlib.Path]: for dirpath, _, filenames in os.walk(root_path): dirpath_path = pathlib.Path(dirpath).relative_to(root_path) + # Skip __pycache__ directories + if dirpath_path == "__pycache__": + continue + # Add this directory file_set.update((dirpath_path,)) # Add any files in it @@ -76,8 +80,6 @@ def test_package_generation( pathlib.Path("src/cookiecutter_test/__init__.py"), pathlib.Path("tests"), pathlib.Path("tests/test_dummy.py"), - pathlib.Path("tests/__pycache__"), - pathlib.PosixPath("tests/__pycache__/test_dummy.cpython-*-pytest-*.pyc"), } actual_files = get_all_files_folders(test_project_dir) From f8e0fb8af71b2ecb92df8fca9884e3073e6845e3 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 12:48:09 +0100 Subject: [PATCH 12/21] Filter `.git` and `__pycache__` --- tests/test_package_generation.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 735a40f5..605b65d6 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -18,10 +18,6 @@ def get_all_files_folders(root_path: pathlib.Path) -> set[pathlib.Path]: for dirpath, _, filenames in os.walk(root_path): dirpath_path = pathlib.Path(dirpath).relative_to(root_path) - # Skip __pycache__ directories - if dirpath_path == "__pycache__": - continue - # Add this directory file_set.update((dirpath_path,)) # Add any files in it @@ -83,9 +79,11 @@ def test_package_generation( } actual_files = get_all_files_folders(test_project_dir) - # Filter out anything under .git/ to make comparison easier + # Filter out anything under specific directories to make comparison easier actual_files = actual_files - { - a for a in actual_files if len(a.parts) > 1 and a.parts[0] == ".git" + a + for a in actual_files + if len(a.parts) > 1 and a.parts[0] in (".git", "__pycache__") } assert actual_files == expected_files From a65a0ea63d36dc1f4f58d1efd4a71d2c89ad37af Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 13:00:24 +0100 Subject: [PATCH 13/21] Remove length in filter --- tests/test_package_generation.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 605b65d6..7b4bcfc2 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -81,9 +81,7 @@ def test_package_generation( actual_files = get_all_files_folders(test_project_dir) # Filter out anything under specific directories to make comparison easier actual_files = actual_files - { - a - for a in actual_files - if len(a.parts) > 1 and a.parts[0] in (".git", "__pycache__") + a for a in actual_files if a.parts[0] in (".git", "__pycache__") } assert actual_files == expected_files From 5ea14b2bd9442d2f87a4efd89f62876a77509f45 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 13:06:20 +0100 Subject: [PATCH 14/21] Check length --- tests/test_package_generation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 7b4bcfc2..94cbc2bc 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -81,7 +81,9 @@ def test_package_generation( actual_files = get_all_files_folders(test_project_dir) # Filter out anything under specific directories to make comparison easier actual_files = actual_files - { - a for a in actual_files if a.parts[0] in (".git", "__pycache__") + a + for a in actual_files + if len(a.parts) > 0 and a.parts[0] in (".git", "__pycache__") } assert actual_files == expected_files From a9f695160bb02ba2b68b9603dd56187154835bbf Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 15:13:35 +0100 Subject: [PATCH 15/21] Try `startswith` --- tests/test_package_generation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 94cbc2bc..c5014983 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -80,10 +80,10 @@ def test_package_generation( actual_files = get_all_files_folders(test_project_dir) # Filter out anything under specific directories to make comparison easier - actual_files = actual_files - { - a - for a in actual_files - if len(a.parts) > 0 and a.parts[0] in (".git", "__pycache__") + actual_files = { + path + for path in actual_files + if not str(path).startswith((".git/", "__pycache__/")) } assert actual_files == expected_files From 64193a4f04c71b26b8540543579aa31685172f50 Mon Sep 17 00:00:00 2001 From: David Stansby Date: Fri, 11 Oct 2024 15:15:00 +0100 Subject: [PATCH 16/21] Fix test --- tests/test_package_generation.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index c5014983..df0685ee 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -46,7 +46,6 @@ def test_package_generation( # Check main files and directories inside expected_files: set[pathlib.Path] = { pathlib.Path(), - pathlib.Path(".git"), pathlib.Path(".github"), pathlib.Path(".github/ISSUE_TEMPLATE"), pathlib.Path(".github/ISSUE_TEMPLATE/bug_report.yml"), @@ -80,10 +79,11 @@ def test_package_generation( actual_files = get_all_files_folders(test_project_dir) # Filter out anything under specific directories to make comparison easier - actual_files = { - path - for path in actual_files - if not str(path).startswith((".git/", "__pycache__/")) + actual_files = actual_files - { + a + for a in actual_files + if len(a.parts) > 0 + and (a.parts[0] == ".git" or "__pycache__" in a.parts or ".DS_Store" in a.parts) } assert actual_files == expected_files From 7d99c7c36a4a4bf35488121516049b5494bb1ce8 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 15:18:23 +0100 Subject: [PATCH 17/21] `__pycache__` can feature anywhere --- tests/test_package_generation.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index df0685ee..464d5aa6 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -79,11 +79,10 @@ def test_package_generation( actual_files = get_all_files_folders(test_project_dir) # Filter out anything under specific directories to make comparison easier - actual_files = actual_files - { - a - for a in actual_files - if len(a.parts) > 0 - and (a.parts[0] == ".git" or "__pycache__" in a.parts or ".DS_Store" in a.parts) + actual_files = { + path + for path in actual_files + if not (str(path).startswith(".git/") or "__pycache__" in path.parts) } assert actual_files == expected_files From 7b21e0ff83e26e6094d1716016cd7f328526b76a Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 15:23:01 +0100 Subject: [PATCH 18/21] Restore `.git` folder --- tests/test_package_generation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 464d5aa6..55060960 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -46,6 +46,7 @@ def test_package_generation( # Check main files and directories inside expected_files: set[pathlib.Path] = { pathlib.Path(), + pathlib.Path(".git"), pathlib.Path(".github"), pathlib.Path(".github/ISSUE_TEMPLATE"), pathlib.Path(".github/ISSUE_TEMPLATE/bug_report.yml"), From b223145f787da1b126665d47bd1c10478f84a84d Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 15:29:01 +0100 Subject: [PATCH 19/21] Revert "Restore `.git` folder" This reverts commit 7b21e0ff83e26e6094d1716016cd7f328526b76a. --- tests/test_package_generation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 55060960..464d5aa6 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -46,7 +46,6 @@ def test_package_generation( # Check main files and directories inside expected_files: set[pathlib.Path] = { pathlib.Path(), - pathlib.Path(".git"), pathlib.Path(".github"), pathlib.Path(".github/ISSUE_TEMPLATE"), pathlib.Path(".github/ISSUE_TEMPLATE/bug_report.yml"), From 79ca8505b392a84a318dd76b3a3e4f26469e79b9 Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 15:29:09 +0100 Subject: [PATCH 20/21] Revert "`__pycache__` can feature anywhere" This reverts commit 7d99c7c36a4a4bf35488121516049b5494bb1ce8. --- tests/test_package_generation.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index 464d5aa6..df0685ee 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -79,10 +79,11 @@ def test_package_generation( actual_files = get_all_files_folders(test_project_dir) # Filter out anything under specific directories to make comparison easier - actual_files = { - path - for path in actual_files - if not (str(path).startswith(".git/") or "__pycache__" in path.parts) + actual_files = actual_files - { + a + for a in actual_files + if len(a.parts) > 0 + and (a.parts[0] == ".git" or "__pycache__" in a.parts or ".DS_Store" in a.parts) } assert actual_files == expected_files From 9c2516f77a441ca884877c9917fc90309061832a Mon Sep 17 00:00:00 2001 From: "Patrick J. Roddy" Date: Fri, 11 Oct 2024 15:30:10 +0100 Subject: [PATCH 21/21] Simplify David's solution --- tests/test_package_generation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_package_generation.py b/tests/test_package_generation.py index df0685ee..71925b63 100644 --- a/tests/test_package_generation.py +++ b/tests/test_package_generation.py @@ -79,11 +79,10 @@ def test_package_generation( actual_files = get_all_files_folders(test_project_dir) # Filter out anything under specific directories to make comparison easier - actual_files = actual_files - { + actual_files = { a for a in actual_files - if len(a.parts) > 0 - and (a.parts[0] == ".git" or "__pycache__" in a.parts or ".DS_Store" in a.parts) + if not (a.parts and (a.parts[0] == ".git" or "__pycache__" in a.parts)) } assert actual_files == expected_files