Skip to content

Commit

Permalink
Merge pull request #61 from pytest-dev/modernize
Browse files Browse the repository at this point in the history
Modernize
  • Loading branch information
bluetech authored Jan 19, 2024
2 parents 6ee0aba + b4bc84c commit c343a9a
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 172 deletions.
16 changes: 4 additions & 12 deletions .github/workflows/run-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- environment: "py36"
python: "3.6"
- environment: "py37"
python: "3.7"
- environment: "py38"
python: "3.8"
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox
run: pip install tox
- name: Run tox
run: tox -e py
24 changes: 11 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ There you go - you just created a minimal pytest plugin:
pytest-awesome/
├── LICENSE
├── README.rst
├── docs
│   └── index.md
── mkdocs.yml
├── pytest_awesome.py
── setup.py
├── pyproject.toml
── src
│ └── pytest_awesome
├── __init__.py
│ └── plugin.py
├── tests
   ├── conftest.py
   └── test_awesome.py
├── conftest.py
└── test_awesome.py
└── tox.ini
```


## Features

- Installable [PyPI] package featuring a `setup.py`.
- Installable [PyPI] package featuring a `pyproject.toml`.
- Test suite running [tox] and [pytest] that makes sure your plugin is working
as expected
- Working example code for a fixture, a cli option, as well as a pytest.ini
Expand All @@ -78,15 +78,13 @@ pytest-awesome/
If you plan on submitting your plugin to the [pytest-dev organization] you need
to meet the following requirements:

- PyPI presence with a setup.py that contains a license, pytest-
- PyPI presence with a pyproject.toml that contains a license, pytest-
prefixed, version number, authors, short and long description.
- a tox.ini for running tests using tox.
- a README describing how to use the plugin and on which platforms
it runs.
- a LICENSE file or equivalent containing the licensing information,
with matching info in setup.py.
- an issue tracker unless you rather want to use the core pytest
issue tracker.
- a LICENSE file or equivalent containing the licensing information.
- an issue tracker

Please see the official guidelines at [Submit a Plugin].

Expand Down
2 changes: 1 addition & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"module_name": "{{ cookiecutter.plugin_name|lower|replace('-', '_') }}",
"short_description": "A simple plugin to use with pytest",
"version": "0.1.0",
"pytest_version": "3.5.0",
"pytest_version": "6.2.0",
"docs_tool": [
"mkdocs",
"sphinx",
Expand Down
11 changes: 4 additions & 7 deletions docs/user-guide/publish-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Essentially pytest plugins are not different from any other Python Package, so
you may want to create a distribution and submit it to the Python Package Index
([PyPI]).

By doing so, enables your users to easily install via ``easy-install`` or
``pip``.
By doing so, enables your users to easily install via ``pip``.

## Python Package Index

Expand All @@ -24,15 +23,13 @@ Please see the official [Python Packaging User Guide] for detailed information.
If you plan on submitting your plugin to the [pytest-dev organization] you need
to meet the following requirements:

- PyPI presence with a setup.py that contains a license, pytest-
- PyPI presence with a pyproject.toml that contains a license, pytest-
prefixed, version number, authors, short and long description.
- a tox.ini for running tests using tox.
- a README describing how to use the plugin and on which platforms
it runs.
- a LICENSE file or equivalent containing the licensing information,
with matching info in setup.py.
- an issue tracker unless you rather want to use the core pytest
issue tracker.
- a LICENSE file or equivalent containing the licensing information.
- an issue tracker.

Please see the official guidelines at [Submit a Plugin].

Expand Down
11 changes: 7 additions & 4 deletions docs/user-guide/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ Once you answered to the questions, Cookiecutter renders the the project:
pytest-awesome/
├── LICENSE
├── README.rst
├── pytest_awesome.py
├── setup.py
├── pyproject.toml
├── src
│ └── pytest_awesome
│ ├── __init__.py
│ └── plugin.py
├── tests
   ├── conftest.py
   └── test_awesome.py
├── conftest.py
└── test_awesome.py
└── tox.ini
```

Expand Down
1 change: 0 additions & 1 deletion hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import logging
import os
Expand Down
1 change: 0 additions & 1 deletion hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import logging
import re
Expand Down
5 changes: 0 additions & 5 deletions pytest-{{cookiecutter.plugin_name}}/MANIFEST.in

This file was deleted.

44 changes: 12 additions & 32 deletions pytest-{{cookiecutter.plugin_name}}/appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,20 @@
# What Python version is installed where:
# https://www.appveyor.com/docs/build-environment/#python
# https://www.appveyor.com/docs/lang/python/
---
image:
- Visual Studio 2019

environment:
matrix:
- PYTHON: "C:\\Python35"
TOX_ENV: "py35"
- TOXENV: "py38"
- TOXENV: "py39"
- TOXENV: "py310"
- TOXENV: "py311"
- TOXENV: "py312"

- PYTHON: "C:\\Python36"
TOX_ENV: "py36"

- PYTHON: "C:\\Python37"
TOX_ENV: "py37"

- PYTHON: "C:\\Python38"
TOX_ENV: "py38"

init:
- "%PYTHON%/python -V"
- "%PYTHON%/python -c \"import struct;print( 8 * struct.calcsize(\'P\'))\""
build: false

install:
- "%PYTHON%/Scripts/easy_install -U pip"
- "%PYTHON%/Scripts/pip install tox"
- "%PYTHON%/Scripts/pip install wheel"

build: false # Not a C# project, build stuff at the test step instead.
- py -m pip install tox

test_script:
- "%PYTHON%/Scripts/tox -e %TOX_ENV%"

after_test:
- "%PYTHON%/python setup.py bdist_wheel"
- ps: "ls dist"

artifacts:
- path: dist\*

#on_success:
# - TODO: upload the content of dist/*.whl to a public wheelhouse
- py -m tox
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# pytest-{{cookiecutter.plugin_name}} documentation build configuration file, created by
# sphinx-quickstart on Thu Oct 1 00:43:18 2015.
#
Expand Down
53 changes: 53 additions & 0 deletions pytest-{{cookiecutter.plugin_name}}/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[build-system]
requires = [
"setuptools>=61.0.0",
]
build-backend = "setuptools.build_meta"

[project]
name = "pytest-{{cookiecutter.plugin_name}}"
description = "{{cookiecutter.short_description}}"
version = "{{cookiecutter.version}}"
readme = "README.rst"
requires-python = ">=3.8"
authors = [
{ name = "{{cookiecutter.full_name}}", email = "{{cookiecutter.email}}" },
]
maintainers = [
{ name = "{{cookiecutter.full_name}}", email = "{{cookiecutter.email}}" },
]
license = {file = "LICENSE"}
classifiers = [
"Framework :: Pytest",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Topic :: Software Development :: Testing",
"Operating System :: OS Independent",
"Programming Language :: Python",
"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 :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
{% if cookiecutter.license == "MIT" -%}
"License :: OSI Approved :: MIT License",
{%- elif cookiecutter.license == "BSD-3" -%}
"License :: OSI Approved :: BSD License",
{%- elif cookiecutter.license == "GNU GPL v3.0+" -%}
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
{%- elif cookiecutter.license == "Apache Software License 2.0" -%}
"License :: OSI Approved :: Apache Software License",
{%- elif cookiecutter.license == "Mozilla Public License 2.0" -%}
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
{%- endif %}
]
dependencies = [
"pytest>={{cookiecutter.pytest_version}}",
]
[project.urls]
Repository = "https://github.com/{{cookiecutter.github_username}}/pytest-{{cookiecutter.plugin_name}}"
[project.entry-points.pytest11]
django = "pytest_{{cookiecutter.module_name}}.plugin"
60 changes: 0 additions & 60 deletions pytest-{{cookiecutter.plugin_name}}/setup.py

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

import pytest


Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
# -*- coding: utf-8 -*-


def test_bar_fixture(testdir):
def test_bar_fixture(pytester):
"""Make sure that pytest accepts our fixture."""

# create a temporary pytest test module
testdir.makepyfile("""
pytester.makepyfile("""
def test_sth(bar):
assert bar == "europython2015"
""")

# run pytest with the following cmd args
result = testdir.runpytest(
result = pytester.runpytest(
'--foo=europython2015',
'-v'
)
Expand All @@ -25,8 +22,8 @@ def test_sth(bar):
assert result.ret == 0


def test_help_message(testdir):
result = testdir.runpytest(
def test_help_message(pytester):
result = pytester.runpytest(
'--help',
)
# fnmatch_lines does an assertion internally
Expand All @@ -36,13 +33,13 @@ def test_help_message(testdir):
])


def test_hello_ini_setting(testdir):
testdir.makeini("""
def test_hello_ini_setting(pytester):
pytester.makeini("""
[pytest]
HELLO = world
""")

testdir.makepyfile("""
pytester.makepyfile("""
import pytest
@pytest.fixture
Expand All @@ -53,7 +50,7 @@ def test_hello_world(hello):
assert hello == 'world'
""")

result = testdir.runpytest('-v')
result = pytester.runpytest('-v')

# fnmatch_lines does an assertion internally
result.stdout.fnmatch_lines([
Expand Down
Loading

0 comments on commit c343a9a

Please sign in to comment.