From 0f442c9d4134e7ddfc505265fcbd105e73b96ee4c480fb3de25bfafd897dac6e Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Tue, 25 Nov 2025 11:42:43 +1100 Subject: [PATCH] - Update to 0.6.0 * Check both py and pyi files. * Adopt to pytest 7. * Remove no longer compatible tests. * Move project metadata to new home. - Update URL. - Refresh fix-pytest-makefile.patch to match what was merged upstream. --- fix-pytest-makefile.patch | 239 ++++++++++++++++++++++++++++++++---- pytest-black-0.3.12.tar.gz | 3 - pytest_black-0.6.0.tar.gz | 3 + python-pytest-black.changes | 11 ++ python-pytest-black.spec | 16 +-- 5 files changed, 238 insertions(+), 34 deletions(-) delete mode 100644 pytest-black-0.3.12.tar.gz create mode 100644 pytest_black-0.6.0.tar.gz diff --git a/fix-pytest-makefile.patch b/fix-pytest-makefile.patch index c0cc27c..5f84434 100644 --- a/fix-pytest-makefile.patch +++ b/fix-pytest-makefile.patch @@ -1,46 +1,239 @@ -From 475cf71aa9de3ededa972ffb36fb47ad79278531 Mon Sep 17 00:00:00 2001 -From: Ben Greiner -Date: Mon, 15 Mar 2021 11:42:27 +0100 -Subject: [PATCH] fix pytest.tmpdir.makefile call +From edcbcae7d55a992e785c7fc001f9d3880b197ea2 Mon Sep 17 00:00:00 2001 +From: Frank Harrison +Date: Tue, 28 Dec 2021 12:21:00 +0000 +Subject: [PATCH] fix(tests): Updates pytest fixture and Path uses - no + functional change +Here we update API calls to use the latest reccomended: + * all 'testdir' fixtures now use the prefered 'pytester' fixture (the + same in all usecases for pytest-black). + * all 'Path.write' uses now use the more explicit `Path.write_text' api + instead. + * we replace `makefile("pyproject.toml", ...` with `makepyprojecttoml(` + which is clearly defined just for this usecase. + +There should be no functional change with this patch, except that older +python versions are probably no longer supported. --- - tests/test_black.py | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) + tests/test_black.py | 97 ++++++++++++++++++++++----------------------- + 1 file changed, 47 insertions(+), 50 deletions(-) diff --git a/tests/test_black.py b/tests/test_black.py -index 0405169..a7a6026 100644 +index 0405169..29af9c2 100644 --- a/tests/test_black.py +++ b/tests/test_black.py -@@ -72,8 +72,8 @@ def test_exclude(testdir): +@@ -6,101 +6,99 @@ + pytestmark = pytest.mark.usefixtures('black_available') + + +-def test_help_message(testdir): +- result = testdir.runpytest("--help") ++def test_help_message(pytester): ++ result = pytester.runpytest("--help") + result.stdout.fnmatch_lines(["*--black*enable format checking with black"]) + + +-def test_fail(testdir): ++def test_fail(pytester): + """Assert test fails due to single quoted strings + """ +- testdir.makepyfile( ++ pytester.makepyfile( + """ + def hello(): + print('Hello, world') + """ + ) +- result = testdir.runpytest("--black") ++ result = pytester.runpytest("--black") + result.assert_outcomes(failed=1) + + +-def test_pass(testdir): ++def test_pass(pytester): + """Assert test passes when no formatting issues are found + """ +- p = testdir.makepyfile( ++ p = pytester.makepyfile( + """ + def hello(): + print("Hello, world!") + """ + ) +- # replace trailing newline (stripped by testdir.makepyfile) +- p = p.write(p.read() + "\n") ++ # replace trailing newline (stripped by pytester.makepyfile) ++ p = p.write_text(p.read_text() + "\n") + +- result = testdir.runpytest("--black") ++ result = pytester.runpytest("--black") + result.assert_outcomes(passed=1) + + +-def test_mtime_cache(testdir): ++def test_mtime_cache(pytester): + """Assert test is skipped when file hasn't changed + """ +- p = testdir.makepyfile( ++ p = pytester.makepyfile( + """ + def hello(): + print("Hello, world!") + """ + ) +- # replace trailing newline (stripped by testdir.makepyfile) +- contents = p.read() + "\n" +- p.write(contents) ++ # replace trailing newline (stripped by pytester.makepyfile) ++ contents = p.read_text() + "\n" ++ p.write_text(contents) + + # Test once to populate the cache +- result = testdir.runpytest("--black") ++ result = pytester.runpytest("--black") + result.assert_outcomes(passed=1) + + # Run it again, it should be skipped +- result = testdir.runpytest("--black", "-rs") ++ result = pytester.runpytest("--black", "-rs") + result.assert_outcomes(skipped=1) + result.stdout.fnmatch_lines(["SKIP*previously passed black format checks"]) + + # Update the file and test again. +- p.write(contents) +- result = testdir.runpytest("--black") ++ p.write_text(contents) ++ result = pytester.runpytest("--black") + result.assert_outcomes(passed=1) + + +-def test_exclude(testdir): ++def test_exclude(pytester): """Assert test is skipped if path is excluded even if also included """ - testdir.makefile( +- testdir.makefile( - "pyproject.toml", -- """ -+ ".toml", -+ pyproject = """ ++ pytester.makepyprojecttoml( + """ [tool.black] include = 'test_exclude.py' exclude = '.*' -@@ -100,8 +100,8 @@ def test_exclude_folder(testdir): + """, + ) +- p = testdir.makepyfile( ++ p = pytester.makepyfile( + """ + def hello(): + print("Hello, world!") + """ + ) + +- # replace trailing newline (stripped by testdir.makepyfile) +- p = p.write(p.read() + "\n") ++ # replace trailing newline (stripped by pytester.makepyfile) ++ p = p.write_text(p.read_text() + "\n") + + # Rename pyproject.toml ¯\_(ツ)_/¯ +- testdir.run("mv", "test_exclude.pyproject.toml", "pyproject.toml") ++ pytester.run("mv", "test_exclude.pyproject.toml", "pyproject.toml") + +- result = testdir.runpytest("--black") ++ result = pytester.runpytest("--black") + result.assert_outcomes(skipped=1, passed=0) + + +-def test_exclude_folder(testdir): ++def test_exclude_folder(pytester): """Assert test is skipped for files in a folder """ - testdir.makefile( +- testdir.makefile( - "pyproject.toml", -- """ -+ ".toml", -+ pyproject = """ ++ pytester.makepyprojecttoml( + """ [tool.black] exclude = ''' - ( -@@ -137,8 +137,8 @@ def test_include(testdir): +@@ -113,65 +111,64 @@ def test_exclude_folder(testdir): + ''' + """, + ) +- p = testdir.makepyfile( ++ p = pytester.makepyfile( + """ + def hello(): + print("Hello, world!") + """ + ) +- # replace trailing newline (stripped by testdir.makepyfile) +- p = p.write(p.read() + "\n") ++ # replace trailing newline (stripped by pytester.makepyfile) ++ p = p.write_text(p.read_text() + "\n") + + # Move file into folder that should be excluded +- ignore_folder = testdir.mkdir("ignore_folder") +- testdir.run("mv", "test_exclude_folder.py", ignore_folder) ++ ignore_folder = pytester.mkdir("ignore_folder") ++ pytester.run("mv", "test_exclude_folder.py", ignore_folder) + + # Rename pyproject.toml ¯\_(ツ)_/¯ +- testdir.run("mv", "test_exclude_folder.pyproject.toml", "pyproject.toml") ++ pytester.run("mv", "test_exclude_folder.pyproject.toml", "pyproject.toml") + +- result = testdir.runpytest("--black") ++ result = pytester.runpytest("--black") + result.assert_outcomes(skipped=1, passed=0) + + +-def test_include(testdir): ++def test_include(pytester): """Assert test is not skipped if path is included but not excluded """ - testdir.makefile( +- testdir.makefile( - "pyproject.toml", -- """ -+ ".toml", -+ pyproject = """ ++ pytester.makepyprojecttoml( + """ [tool.black] include = 'test_include' """, + ) +- p = testdir.makepyfile( ++ p = pytester.makepyfile( + """ + def hello(): + print("Hello, world!") + """ + ) + +- # replace trailing newline (stripped by testdir.makepyfile) +- p = p.write(p.read() + "\n") ++ # replace trailing newline (stripped by pytester.makepyfile) ++ p = p.write_text(p.read_text() + "\n") + + # Rename pyproject.toml ¯\_(ツ)_/¯ +- testdir.run("mv", "test_include.pyproject.toml", "pyproject.toml") ++ pytester.run("mv", "test_include.pyproject.toml", "pyproject.toml") + +- result = testdir.runpytest("--black") ++ result = pytester.runpytest("--black") + result.assert_outcomes(skipped=0, passed=1) + + +-def test_pytest_deprecation_warning(testdir): ++def test_pytest_deprecation_warning(pytester): + """Assert no deprecation warning is raised during test.""" +- p = testdir.makepyfile( ++ p = pytester.makepyfile( + """ + def hello(): + print("Hello, world!") + """ + ) +- # replace trailing newline (stripped by testdir.makepyfile) +- p = p.write(p.read() + "\n") ++ # replace trailing newline (stripped by pytester.makepyfile) ++ p = p.write_text(p.read_text() + "\n") + +- result = testdir.runpytest("--black") ++ result = pytester.runpytest("--black") + result.assert_outcomes(passed=1) + + out = "\n".join(result.stdout.lines) diff --git a/pytest-black-0.3.12.tar.gz b/pytest-black-0.3.12.tar.gz deleted file mode 100644 index b794803..0000000 --- a/pytest-black-0.3.12.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1d339b004f764d6cd0f06e690f6dd748df3d62e6fe1a692d6a5500ac2c5b75a5 -size 6898 diff --git a/pytest_black-0.6.0.tar.gz b/pytest_black-0.6.0.tar.gz new file mode 100644 index 0000000..81f6fe7 --- /dev/null +++ b/pytest_black-0.6.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ecb77455f379805cb4bd8f45a813a3754c3bbee3199adf1b3665c0dfd086b511 +size 6281 diff --git a/python-pytest-black.changes b/python-pytest-black.changes index 371acc9..74648a8 100644 --- a/python-pytest-black.changes +++ b/python-pytest-black.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Tue Nov 25 00:42:23 UTC 2025 - Steve Kowalik + +- Update to 0.6.0: + * Check both py and pyi files. + * Adopt to pytest 7. + * Remove no longer compatible tests. + * Move project metadata to new home. +- Update URL. +- Refresh fix-pytest-makefile.patch to match what was merged upstream. + ------------------------------------------------------------------- Wed May 7 06:47:48 UTC 2025 - Steve Kowalik diff --git a/python-pytest-black.spec b/python-pytest-black.spec index 355b66c..eafdb35 100644 --- a/python-pytest-black.spec +++ b/python-pytest-black.spec @@ -17,14 +17,14 @@ Name: python-pytest-black -Version: 0.3.12 +Version: 0.6.0 Release: 0 Summary: Black format checking plugin for pytest License: MIT -URL: https://github.com/shopkeep/pytest-black -Source: https://files.pythonhosted.org/packages/source/p/pytest-black/pytest-black-%{version}.tar.gz -# PATCH-FIX-UPSTREAM fix-pytest-makefile.patch -- gh#shopkeep/pytest-black#53 -Patch0: https://github.com/shopkeep/pytest-black/pull/53.patch#/fix-pytest-makefile.patch +URL: https://github.com/coherent-oss/pytest-black +Source: https://files.pythonhosted.org/packages/source/p/pytest-black/pytest_black-%{version}.tar.gz +# PATCH-FIX-UPSTREAM Update pytest fixtures +Patch0: https://github.com/coherent-oss/pytest-black/commit/75e0012.patch#/fix-pytest-makefile.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools_scm} BuildRequires: %{python_module setuptools} @@ -32,12 +32,12 @@ BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-black -Requires: python-pytest >= 3.5.0 +Requires: python-pytest >= 7 Requires: python-toml BuildArch: noarch # SECTION test requirements BuildRequires: %{python_module black} -BuildRequires: %{python_module pytest >= 3.5.0} +BuildRequires: %{python_module pytest >= 7} BuildRequires: %{python_module toml} # /SECTION %python_subpackages @@ -46,7 +46,7 @@ BuildRequires: %{python_module toml} A pytest plugin to enable format checking with black. %prep -%autosetup -p1 -n pytest-black-%{version} +%autosetup -p1 -n pytest_black-%{version} %build %pyproject_wheel