-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afb13a0
commit f779397
Showing
18 changed files
with
412 additions
and
112 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @gaborbernat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
name: check | ||
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
- cron: "0 8 * * *" | ||
|
||
concurrency: | ||
group: check-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
name: test ${{ matrix.py }} - ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
py: | ||
- "3.11.0-rc.2" | ||
- "3.10" | ||
- "3.9" | ||
- "3.8" | ||
- "3.7" | ||
os: | ||
- ubuntu-22.04 | ||
|
||
steps: | ||
- name: Setup python for tox | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install tox | ||
run: python -m pip install tox | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup python for test ${{ matrix.py }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.py }} | ||
- name: Pick environment to run | ||
run: | | ||
import codecs; import os; import sys | ||
env = "TOXENV=py{}{}\n".format(*sys.version_info[0:2]) | ||
print("Picked:\n{}for{}".format(env, sys.version)) | ||
with codecs.open(os.environ["GITHUB_ENV"], "a", "utf-8") as file_handler: | ||
file_handler.write(env) | ||
shell: python | ||
- name: Setup test suite | ||
run: tox -vv --notest | ||
- name: Run test suite | ||
run: tox --skip-pkg-install | ||
env: | ||
CI_RUN: "yes" | ||
|
||
check: | ||
name: ${{ matrix.tox_env }} - ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-22.04 | ||
tox_env: | ||
- dev | ||
- type | ||
- readme | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Python "3.10" | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install tox | ||
run: python -m pip install tox | ||
- name: Setup test suite | ||
run: tox -vv --notest -e ${{ matrix.tox_env }} | ||
- name: Run test suite | ||
run: tox --skip-pkg-install -e ${{ matrix.tox_env }} | ||
|
||
publish: | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
needs: [ test, check ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup python to build package | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install build | ||
run: python -m pip install build | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Build sdist and wheel | ||
run: python -m build -s -w . -o dist | ||
- name: Publish to PyPi | ||
uses: pypa/gh-action-pypi-publish@v1.5.1 | ||
with: | ||
skip_existing: true | ||
user: __token__ | ||
password: ${{ secrets.pypi_password }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,5 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
*.pyc | ||
*.egg-info | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
/src/pytest_env/version.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: check-ast | ||
- id: check-builtin-literals | ||
- id: check-docstring-first | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
- id: check-toml | ||
- id: debug-statements | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.0.0 | ||
hooks: | ||
- id: pyupgrade | ||
args: [ "--py37-plus" ] | ||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 | ||
hooks: | ||
- id: black | ||
args: [ --safe ] | ||
- repo: https://github.com/asottile/blacken-docs | ||
rev: v1.12.1 | ||
hooks: | ||
- id: blacken-docs | ||
additional_dependencies: [ black==22.10 ] | ||
- repo: https://github.com/pre-commit/pygrep-hooks | ||
rev: v1.9.0 | ||
hooks: | ||
- id: rst-backticks | ||
- repo: https://github.com/tox-dev/tox-ini-fmt | ||
rev: "0.5.2" | ||
hooks: | ||
- id: tox-ini-fmt | ||
args: [ "-p", "fix" ] | ||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 5.0.4 | ||
hooks: | ||
- id: flake8 | ||
additional_dependencies: | ||
- flake8-bugbear==22.9.23 | ||
- flake8-comprehensions==3.10 | ||
- flake8-pytest-style==1.6 | ||
- flake8-spellcheck==0.28 | ||
- flake8-unused-arguments==0.0.11 | ||
- flake8-noqa==1.2.9 | ||
- pep8-naming==0.13.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,47 @@ | ||
# pytest-env | ||
|
||
[![PyPI](https://img.shields.io/pypi/v/pytest-env?style=flat-square)](https://pypi.org/project/pytest-env/) | ||
[![Supported Python | ||
versions](https://img.shields.io/pypi/pyversions/pytest-env.svg)](https://pypi.org/project/pytest-env/) | ||
[![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) | ||
[![Code style: | ||
black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) | ||
[![Downloads](https://pepy.tech/badge/pytest-env/month)](https://pepy.tech/project/pytest-env/month) | ||
|
||
This is a py.test plugin that enables you to set environment variables in the pytest.ini file. | ||
|
||
## Installation | ||
|
||
Install with pip: | ||
|
||
pip install pytest-env | ||
|
||
Uninstall with pip: | ||
|
||
pip uninstall pytest-env | ||
```shell | ||
pip install pytest-env | ||
``` | ||
|
||
## Usage | ||
|
||
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: | ||
|
||
[pytest] | ||
env = | ||
HOME=~/tmp | ||
RUN_ENV=test | ||
```ini | ||
[pytest] | ||
env = | ||
HOME=~/tmp | ||
RUN_ENV=test | ||
``` | ||
|
||
You can use `D:` (default) as prefix if you don't want to override existing environment variables: | ||
|
||
[pytest] | ||
env = | ||
D:HOME=~/tmp | ||
D:RUN_ENV=test | ||
```ini | ||
[pytest] | ||
env = | ||
D:HOME=~/tmp | ||
D:RUN_ENV=test | ||
``` | ||
|
||
Lastly, you can use existing environment variables using a python-like format: | ||
|
||
[pytest] | ||
env = | ||
RUN_PATH=/run/path/{USER} | ||
```ini | ||
[pytest] | ||
env = | ||
RUN_PATH=/run/path/{USER} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
[build-system] | ||
build-backend = "hatchling.build" | ||
requires = ["hatchling>=1.11", "hatch-vcs>=0.2"] | ||
|
||
[project] | ||
name = "pytest-env" | ||
description = "py.test plugin that allows you to add environment variables." | ||
readme = "README.md" | ||
license.file = "LICENSE" | ||
maintainers = [{ name = "Bernát Gábor", email = "gaborjbernat@gmail.com" }] | ||
urls.Documentation = "https://bump-deps-index.readthedocs.io" | ||
urls.Homepage = "https://github.com/pytest-dev/pytest-env" | ||
urls.Source = "https://github.com/pytest-dev/pytest-env" | ||
urls.Tracker = "https://github.com/pytest-dev/pytest-env/issues" | ||
requires-python = ">=3.7" | ||
dependencies = ["pytest>=7.1.3"] | ||
optional-dependencies.test = ["coverage>=6.5", "pytest-mock>=3.10", "covdefaults>=2.2"] | ||
keywords = ["pytest", "env"] | ||
classifiers = [ | ||
"Development Status :: 5 - Production/Stable", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
] | ||
dynamic = ["version"] | ||
|
||
[project.entry-points.pytest11] | ||
env = "pytest_env.plugin" | ||
|
||
[tool.hatch] | ||
build.hooks.vcs.version-file = "src/pytest_env/version.py" | ||
version.source = "vcs" | ||
|
||
[tool.black] | ||
line-length = 120 | ||
|
||
[tool.coverage] | ||
source = ["${_COVERAGE_SRC}", "${_COVERAGE_TEST}"] | ||
run.dynamic_context = "test_function" | ||
run.plugins = ["covdefaults"] | ||
run.parallel = true | ||
report.fail_under = 100 | ||
html.show_contexts = true | ||
html.skip_covered = false | ||
paths.source = [ | ||
"src", | ||
".tox*/*/lib/python*/site-packages", | ||
".tox*/pypy*/site-packages", | ||
".tox*\\*\\Lib\\site-packages", | ||
"*/src", | ||
"*\\src", | ||
] | ||
|
||
[tool.mypy] | ||
python_version = "3.10" | ||
show_error_codes = true | ||
strict = true | ||
|
||
[tool.isort] | ||
profile = "black" | ||
known_first_party = ["pytest_env"] |
Oops, something went wrong.