Skip to content

Commit

Permalink
Merge pull request #8 from nicoddemus/support-latest-pytest
Browse files Browse the repository at this point in the history
Support latest pytest and make 1.0 release
  • Loading branch information
nicoddemus committed Mar 4, 2024
2 parents 94c8210 + 5c3cbfe commit fa67902
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 96 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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/*
62 changes: 0 additions & 62 deletions .github/workflows/main.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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`
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.0.0
=====

- Require pytest >=7.0 and Python >=3.8.


0.3.0
=====

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools",
"setuptools-scm[toml]",
]
12 changes: 8 additions & 4 deletions pytest_drop_dup_tests.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

26 changes: 14 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import codecs
import os

from setuptools import setup


Expand All @@ -20,26 +18,30 @@ 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",
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",
],
entry_points={"pytest11": ["drop-dup-tests = pytest_drop_dup_tests",],},
entry_points={
"pytest11": [
"drop-dup-tests = pytest_drop_dup_tests",
],
},
)
17 changes: 10 additions & 7 deletions tests/test_drop_dup_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


def test_drop_duplicated_dir(testdir):
testdir.makepyfile(
"""
Expand All @@ -10,7 +7,9 @@ def test_foo():
)
result = testdir.runpytest(".", ".")
result.stdout.fnmatch_lines(
["* 1 passed in *",]
[
"* 1 passed in *",
]
)
assert result.ret == 0

Expand All @@ -27,7 +26,9 @@ def test_foo():
)
result = testdir.runpytest("pkg", "pkg")
result.stdout.fnmatch_lines(
["* 1 passed in *",]
[
"* 1 passed in *",
]
)
assert result.ret == 0

Expand All @@ -45,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 *",
]
)
Expand Down
7 changes: 1 addition & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fa67902

Please sign in to comment.