From 2af848174284d36d8860409d220731a9dbea7c72 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 4 Mar 2024 17:20:54 -0300 Subject: [PATCH 1/3] Upgrade pre-commit hooks --- .pre-commit-config.yaml | 4 ++-- setup.py | 6 +++++- tests/test_drop_dup_tests.py | 8 ++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04daf66..f7e03d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ repos: - repo: https://github.com/ambv/black - rev: 19.10b0 + rev: 24.2.0 hooks: - id: black args: [--safe, --quiet] - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.1.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer diff --git a/setup.py b/setup.py index 07a7af2..8b770a8 100644 --- a/setup.py +++ b/setup.py @@ -41,5 +41,9 @@ def read(fname): "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", ], - entry_points={"pytest11": ["drop-dup-tests = pytest_drop_dup_tests",],}, + entry_points={ + "pytest11": [ + "drop-dup-tests = pytest_drop_dup_tests", + ], + }, ) diff --git a/tests/test_drop_dup_tests.py b/tests/test_drop_dup_tests.py index dd7dd21..ca26892 100644 --- a/tests/test_drop_dup_tests.py +++ b/tests/test_drop_dup_tests.py @@ -10,7 +10,9 @@ def test_foo(): ) result = testdir.runpytest(".", ".") result.stdout.fnmatch_lines( - ["* 1 passed in *",] + [ + "* 1 passed in *", + ] ) assert result.ret == 0 @@ -27,7 +29,9 @@ def test_foo(): ) result = testdir.runpytest("pkg", "pkg") result.stdout.fnmatch_lines( - ["* 1 passed in *",] + [ + "* 1 passed in *", + ] ) assert result.ret == 0 From daf0be81fb0cfc295a4296751df64fd22a4295a6 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 4 Mar 2024 17:27:24 -0300 Subject: [PATCH 2/3] Require pytest>=7 and Python >=3.8 --- .github/workflows/main.yml | 17 +++-------------- CHANGELOG.rst | 6 ++++++ pyproject.toml | 6 ++++++ pytest_drop_dup_tests.py | 12 ++++++++---- setup.cfg | 2 -- setup.py | 16 ++++++---------- tests/test_drop_dup_tests.py | 9 ++++----- tox.ini | 7 +------ 8 files changed, 34 insertions(+), 41 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 81ea766..7bbe15a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,18 +9,7 @@ jobs: strategy: max-parallel: 4 matrix: - tox-env: ["py27", "py36", "py37", "py38", "linting"] - include: - - tox-env: "py27" - python-version: "2.7" - - tox-env: "py36" - python-version: "3.6" - - tox-env: "py37" - python-version: "3.7" - - tox-env: "py38" - python-version: "3.8" - - tox-env: "linting" - python-version: "3.8" + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v1 @@ -34,7 +23,7 @@ jobs: pip install tox - name: Test run: | - tox -e ${{ matrix.tox-env }} + tox -e $py deploy: if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') @@ -47,7 +36,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: "3.8" + python-version: "3.x" - name: Install wheel run: | python -m pip install --upgrade pip diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c7bb5db..afa8a59 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,9 @@ +1.0.0 +===== + +- Require pytest >=7.0 and Python >=3.8. + + 0.3.0 ===== diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9856a46 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,6 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "setuptools", + "setuptools-scm[toml]", +] diff --git a/pytest_drop_dup_tests.py b/pytest_drop_dup_tests.py index 646ccb5..5079773 100644 --- a/pytest_drop_dup_tests.py +++ b/pytest_drop_dup_tests.py @@ -1,13 +1,17 @@ _seen_paths = set() -def pytest_ignore_collect(path, config): - if path.basename == "__init__.py": +def pytest_configure(): + _seen_paths.clear() + + +def pytest_ignore_collect(collection_path): + if collection_path.name == "__init__.py": return None - if path in _seen_paths: + if collection_path in _seen_paths: return True else: - _seen_paths.add(path) + _seen_paths.add(collection_path) return None diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 2a9acf1..0000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[bdist_wheel] -universal = 1 diff --git a/setup.py b/setup.py index 8b770a8..9e7a886 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,3 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - import os import codecs from setuptools import setup @@ -24,19 +21,18 @@ def read(fname): py_modules=["pytest_drop_dup_tests"], setup_requires="setuptools_scm", use_scm_version=True, - install_requires=["pytest>=2.7"], + install_requires=["pytest>=7"], classifiers=[ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Framework :: Pytest", "Intended Audience :: Developers", "Topic :: Software Development :: Testing", "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: Implementation :: CPython", "Operating System :: OS Independent", "License :: OSI Approved :: MIT License", diff --git a/tests/test_drop_dup_tests.py b/tests/test_drop_dup_tests.py index ca26892..c86581f 100644 --- a/tests/test_drop_dup_tests.py +++ b/tests/test_drop_dup_tests.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- - - def test_drop_duplicated_dir(testdir): testdir.makepyfile( """ @@ -49,11 +46,13 @@ def test_bar(): """, } ) - result = testdir.runpytest("tests", "tests/test_foo.py", "-v") + result = testdir.runpytest( + "tests/test_foo.py", "tests/test_foo.py", "tests/test_bar.py", "-v" + ) result.stdout.fnmatch_lines( [ - "tests/test_bar.py::test_bar *", "tests/test_foo.py::test_foo *", + "tests/test_bar.py::test_bar *", "* 2 passed, 1 deselected in *", ] ) diff --git a/tox.ini b/tox.ini index 1ec99e1..8b59910 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,5 @@ [tox] -envlist = py27,py36,py37,py38,linting +envlist = py38,py39,py310,py311,py312 [testenv] commands = pytest {posargs:tests} - -[testenv:linting] -skip_install = True -deps = pre-commit -commands = pre-commit run --all-files --show-diff-on-failure From 5c3cbfeacb0426e294b3708c5f2a236c491f25c5 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Mon, 4 Mar 2024 17:51:18 -0300 Subject: [PATCH 3/3] Split workflows into test and deploy --- .github/workflows/deploy.yml | 38 ++++++++++++++++++++++++++ .github/workflows/main.yml | 51 ---------------------------------- .github/workflows/test.yml | 53 ++++++++++++++++++++++++++++++++++++ README.rst | 2 +- setup.py | 4 ++- 5 files changed, 95 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..00d9a91 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,38 @@ +name: deploy + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + +jobs: + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build and Check Package + uses: hynek/build-and-inspect-python-package@v1.5 + + deploy: + needs: package + runs-on: ubuntu-latest + permissions: + id-token: write + + steps: + - uses: actions/checkout@v3 + + - name: Download Package + uses: actions/download-artifact@v3 + with: + name: Packages + path: dist + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@v1.8.5 + + - name: GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: dist/* diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 7bbe15a..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: main - -on: [push] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - max-parallel: 4 - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - - steps: - - uses: actions/checkout@v1 - - name: Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Dependencies - run: | - python -m pip install --upgrade pip - pip install tox - - name: Test - run: | - tox -e $py - - deploy: - if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - - runs-on: ubuntu-latest - needs: build - - steps: - - uses: actions/checkout@v1 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: "3.x" - - name: Install wheel - run: | - python -m pip install --upgrade pip - pip install wheel setuptools - - name: Build package - run: | - python setup.py sdist bdist_wheel - - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.pypi_token }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..08dee27 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,53 @@ +name: test + +on: + push: + branches: + - master + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build and Check Package + uses: hynek/build-and-inspect-python-package@v1.5 + + test: + needs: package + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + + + steps: + - uses: actions/checkout@v3 + + - name: Download Package + uses: actions/download-artifact@v3 + with: + name: Packages + path: dist + + - name: Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Dependencies + run: | + python -m pip install --upgrade pip + pip install tox + + - name: Test + shell: bash + run: | + tox run -e py --installpkg `find dist/*.tar.gz` diff --git a/README.rst b/README.rst index 7895fbb..4bfc97c 100644 --- a/README.rst +++ b/README.rst @@ -4,7 +4,7 @@ pytest-drop-dup-tests .. image:: http://img.shields.io/pypi/v/pytest-drop-dup-tests.svg :target: https://pypi.python.org/pypi/pytest-drop-dup-tests -.. image:: https://github.com/nicoddemus/pytest-drop-dup-tests/workflows/main/badge.svg +.. image:: https://github.com/nicoddemus/pytest-drop-dup-tests/workflows/test/badge.svg :target: https://github.com/nicoddemus/pytest-drop-dup-tests/actions diff --git a/setup.py b/setup.py index 9e7a886..3f3d163 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ -import os import codecs +import os + from setuptools import setup @@ -17,6 +18,7 @@ def read(fname): license="MIT", url="https://github.com/nicoddemus/pytest-drop-dup-tests", description="A Pytest plugin to drop duplicated tests during collection", + long_description_content_type="text/x-rst", long_description=read("README.rst"), py_modules=["pytest_drop_dup_tests"], setup_requires="setuptools_scm",