Skip to content

Commit f779397

Browse files
authored
Modernize project (#1)
1 parent afb13a0 commit f779397

File tree

18 files changed

+412
-112
lines changed

18 files changed

+412
-112
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @gaborbernat

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/check.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: check
2+
on:
3+
push:
4+
pull_request:
5+
schedule:
6+
- cron: "0 8 * * *"
7+
8+
concurrency:
9+
group: check-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
test:
14+
name: test ${{ matrix.py }} - ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
py:
20+
- "3.11.0-rc.2"
21+
- "3.10"
22+
- "3.9"
23+
- "3.8"
24+
- "3.7"
25+
os:
26+
- ubuntu-22.04
27+
28+
steps:
29+
- name: Setup python for tox
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: "3.10"
33+
- name: Install tox
34+
run: python -m pip install tox
35+
- uses: actions/checkout@v3
36+
with:
37+
fetch-depth: 0
38+
- name: Setup python for test ${{ matrix.py }}
39+
uses: actions/setup-python@v4
40+
with:
41+
python-version: ${{ matrix.py }}
42+
- name: Pick environment to run
43+
run: |
44+
import codecs; import os; import sys
45+
env = "TOXENV=py{}{}\n".format(*sys.version_info[0:2])
46+
print("Picked:\n{}for{}".format(env, sys.version))
47+
with codecs.open(os.environ["GITHUB_ENV"], "a", "utf-8") as file_handler:
48+
file_handler.write(env)
49+
shell: python
50+
- name: Setup test suite
51+
run: tox -vv --notest
52+
- name: Run test suite
53+
run: tox --skip-pkg-install
54+
env:
55+
CI_RUN: "yes"
56+
57+
check:
58+
name: ${{ matrix.tox_env }} - ${{ matrix.os }}
59+
runs-on: ${{ matrix.os }}
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
os:
64+
- ubuntu-22.04
65+
tox_env:
66+
- dev
67+
- type
68+
- readme
69+
steps:
70+
- uses: actions/checkout@v3
71+
with:
72+
fetch-depth: 0
73+
- name: Setup Python "3.10"
74+
uses: actions/setup-python@v4
75+
with:
76+
python-version: "3.10"
77+
- name: Install tox
78+
run: python -m pip install tox
79+
- name: Setup test suite
80+
run: tox -vv --notest -e ${{ matrix.tox_env }}
81+
- name: Run test suite
82+
run: tox --skip-pkg-install -e ${{ matrix.tox_env }}
83+
84+
publish:
85+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
86+
needs: [ test, check ]
87+
runs-on: ubuntu-latest
88+
steps:
89+
- name: Setup python to build package
90+
uses: actions/setup-python@v4
91+
with:
92+
python-version: "3.10"
93+
- name: Install build
94+
run: python -m pip install build
95+
- uses: actions/checkout@v3
96+
with:
97+
fetch-depth: 0
98+
- name: Build sdist and wheel
99+
run: python -m build -s -w . -o dist
100+
- name: Publish to PyPi
101+
uses: pypa/[email protected]
102+
with:
103+
skip_existing: true
104+
user: __token__
105+
password: ${{ secrets.pypi_password }}

.gitignore

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,5 @@
1-
# Byte-compiled / optimized / DLL files
2-
__pycache__/
3-
*.py[cod]
4-
5-
# C extensions
6-
*.so
7-
8-
# Distribution / packaging
9-
.Python
10-
env/
11-
build/
12-
develop-eggs/
1+
*.pyc
2+
*.egg-info
133
dist/
14-
downloads/
15-
eggs/
16-
lib/
17-
lib64/
18-
parts/
19-
sdist/
20-
var/
21-
*.egg-info/
22-
.installed.cfg
23-
*.egg
24-
25-
# PyInstaller
26-
# Usually these files are written by a python script from a template
27-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
28-
*.manifest
29-
*.spec
30-
31-
# Installer logs
32-
pip-log.txt
33-
pip-delete-this-directory.txt
34-
35-
# Unit test / coverage reports
36-
htmlcov/
374
.tox/
38-
.coverage
39-
.cache
40-
nosetests.xml
41-
coverage.xml
42-
43-
# Translations
44-
*.mo
45-
*.pot
46-
47-
# Django stuff:
48-
*.log
49-
50-
# Sphinx documentation
51-
docs/_build/
52-
53-
# PyBuilder
54-
target/
5+
/src/pytest_env/version.py

.pre-commit-config.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.3.0
4+
hooks:
5+
- id: check-ast
6+
- id: check-builtin-literals
7+
- id: check-docstring-first
8+
- id: check-merge-conflict
9+
- id: check-yaml
10+
- id: check-toml
11+
- id: debug-statements
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+
- repo: https://github.com/asottile/pyupgrade
15+
rev: v3.0.0
16+
hooks:
17+
- id: pyupgrade
18+
args: [ "--py37-plus" ]
19+
- repo: https://github.com/PyCQA/isort
20+
rev: 5.10.1
21+
hooks:
22+
- id: isort
23+
- repo: https://github.com/psf/black
24+
rev: 22.10.0
25+
hooks:
26+
- id: black
27+
args: [ --safe ]
28+
- repo: https://github.com/asottile/blacken-docs
29+
rev: v1.12.1
30+
hooks:
31+
- id: blacken-docs
32+
additional_dependencies: [ black==22.10 ]
33+
- repo: https://github.com/pre-commit/pygrep-hooks
34+
rev: v1.9.0
35+
hooks:
36+
- id: rst-backticks
37+
- repo: https://github.com/tox-dev/tox-ini-fmt
38+
rev: "0.5.2"
39+
hooks:
40+
- id: tox-ini-fmt
41+
args: [ "-p", "fix" ]
42+
- repo: https://github.com/PyCQA/flake8
43+
rev: 5.0.4
44+
hooks:
45+
- id: flake8
46+
additional_dependencies:
47+
- flake8-bugbear==22.9.23
48+
- flake8-comprehensions==3.10
49+
- flake8-pytest-style==1.6
50+
- flake8-spellcheck==0.28
51+
- flake8-unused-arguments==0.0.11
52+
- flake8-noqa==1.2.9
53+
- pep8-naming==0.13.2

LICENSE

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
The MIT License (MIT)
1+
MIT License
2+
3+
Copyright (c) 2010-202x The pytest-env developers
24

35
Permission is hereby granted, free of charge, to any person obtaining a copy
46
of this software and associated documentation files (the "Software"), to deal
@@ -16,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1618
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1719
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1820
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
11
# pytest-env
22

3+
[![PyPI](https://img.shields.io/pypi/v/pytest-env?style=flat-square)](https://pypi.org/project/pytest-env/)
4+
[![Supported Python
5+
versions](https://img.shields.io/pypi/pyversions/pytest-env.svg)](https://pypi.org/project/pytest-env/)
6+
[![check](https://github.com/pytest-dev/pytest-env/actions/workflows/check.yml/badge.svg)](https://github.com/pytest-dev/pytest-env/actions/workflows/check.yml)
7+
[![Code style:
8+
black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
9+
[![Downloads](https://pepy.tech/badge/pytest-env/month)](https://pepy.tech/project/pytest-env/month)
10+
311
This is a py.test plugin that enables you to set environment variables in the pytest.ini file.
412

513
## Installation
614

715
Install with pip:
816

9-
pip install pytest-env
10-
11-
Uninstall with pip:
12-
13-
pip uninstall pytest-env
17+
```shell
18+
pip install pytest-env
19+
```
1420

1521
## Usage
1622

1723
In your pytest.ini file add a key value pair with `env` as the key and the environment variables as a line separated list of `KEY=VALUE` entries. The defined variables will be added to the environment before any tests are run:
1824

19-
[pytest]
20-
env =
21-
HOME=~/tmp
22-
RUN_ENV=test
25+
```ini
26+
[pytest]
27+
env =
28+
HOME=~/tmp
29+
RUN_ENV=test
30+
```
2331

2432
You can use `D:` (default) as prefix if you don't want to override existing environment variables:
2533

26-
[pytest]
27-
env =
28-
D:HOME=~/tmp
29-
D:RUN_ENV=test
34+
```ini
35+
[pytest]
36+
env =
37+
D:HOME=~/tmp
38+
D:RUN_ENV=test
39+
```
3040

3141
Lastly, you can use existing environment variables using a python-like format:
3242

33-
[pytest]
34-
env =
35-
RUN_PATH=/run/path/{USER}
43+
```ini
44+
[pytest]
45+
env =
46+
RUN_PATH=/run/path/{USER}
47+
```

pyproject.toml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[build-system]
2+
build-backend = "hatchling.build"
3+
requires = ["hatchling>=1.11", "hatch-vcs>=0.2"]
4+
5+
[project]
6+
name = "pytest-env"
7+
description = "py.test plugin that allows you to add environment variables."
8+
readme = "README.md"
9+
license.file = "LICENSE"
10+
maintainers = [{ name = "Bernát Gábor", email = "[email protected]" }]
11+
urls.Documentation = "https://bump-deps-index.readthedocs.io"
12+
urls.Homepage = "https://github.com/pytest-dev/pytest-env"
13+
urls.Source = "https://github.com/pytest-dev/pytest-env"
14+
urls.Tracker = "https://github.com/pytest-dev/pytest-env/issues"
15+
requires-python = ">=3.7"
16+
dependencies = ["pytest>=7.1.3"]
17+
optional-dependencies.test = ["coverage>=6.5", "pytest-mock>=3.10", "covdefaults>=2.2"]
18+
keywords = ["pytest", "env"]
19+
classifiers = [
20+
"Development Status :: 5 - Production/Stable",
21+
"Intended Audience :: Developers",
22+
"License :: OSI Approved :: MIT License",
23+
"Operating System :: OS Independent",
24+
"Programming Language :: Python",
25+
"Programming Language :: Python :: 3",
26+
"Programming Language :: Python :: 3 :: Only",
27+
"Programming Language :: Python :: Implementation :: CPython",
28+
"Topic :: Software Development :: Libraries :: Python Modules",
29+
]
30+
dynamic = ["version"]
31+
32+
[project.entry-points.pytest11]
33+
env = "pytest_env.plugin"
34+
35+
[tool.hatch]
36+
build.hooks.vcs.version-file = "src/pytest_env/version.py"
37+
version.source = "vcs"
38+
39+
[tool.black]
40+
line-length = 120
41+
42+
[tool.coverage]
43+
source = ["${_COVERAGE_SRC}", "${_COVERAGE_TEST}"]
44+
run.dynamic_context = "test_function"
45+
run.plugins = ["covdefaults"]
46+
run.parallel = true
47+
report.fail_under = 100
48+
html.show_contexts = true
49+
html.skip_covered = false
50+
paths.source = [
51+
"src",
52+
".tox*/*/lib/python*/site-packages",
53+
".tox*/pypy*/site-packages",
54+
".tox*\\*\\Lib\\site-packages",
55+
"*/src",
56+
"*\\src",
57+
]
58+
59+
[tool.mypy]
60+
python_version = "3.10"
61+
show_error_codes = true
62+
strict = true
63+
64+
[tool.isort]
65+
profile = "black"
66+
known_first_party = ["pytest_env"]

0 commit comments

Comments
 (0)