Skip to content

Commit

Permalink
chore: convert from pip/tox to poetry
Browse files Browse the repository at this point in the history
Instead of using tox to setup and control virtualenvs, use poetry to
handle package definition, installation, and virtual environment setup.

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
miketheman committed Apr 10, 2020
1 parent 4a922b8 commit 0aee845
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 118 deletions.
1 change: 0 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ plugins:
exclude_patterns:
- "*.egg-info/"
- .cache/
- .tox/
- __pycache__/
- dist/
- htmlcov/
Expand Down
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[report]
include = *pytest_socket*
25 changes: 7 additions & 18 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,11 @@ jobs:
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
- name: Install and configure poetry
run: |
python -m pip install --upgrade pip
# pip install -r requirements.txt
- name: Test with tox
run: |
pip install tox
tox -e py
# - name: Lint with flake8
# run: |
# pip install flake8
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Test with pytest
# run: |
# pip install pytest
# pytest
python -m pip install poetry
poetry config virtualenvs.create false
- name: Prepare project for development
run: poetry install
- name: Test with pytest
run: poetry run pytest
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ target/
.python-version

.pytest_cache/

# poetry lock file - for libraries only
poetry.lock
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

28 changes: 16 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
.PHONY: all clean test
.PHONY: all clean poetry test dist testrelease release

TOX := $(shell command -v tox 2> /dev/null)
POETRY := $(shell command -v poetry 2> /dev/null)

all: test

clean:
@find . -name \*.pyc -name __pycache__ -delete
@rm -fr .cache/ .coverage* .pytest_cache/ .tox/ *.egg-info/ dist/ htmlcov/
@find . -name \*.pyc -delete
@find . -name __pycache__ -delete
@rm -fr .cache/ .coverage .pytest_cache/ *.egg-info/ dist/ htmlcov/

test:
ifndef TOX
$(error "tox is not available, run `pip install tox`")
poetry.lock pytest_socket.egg-info/ :
ifndef POETRY
$(error "poetry is not available, please install it first.")
endif
@tox
@poetry install

build: clean
@python setup.py sdist
test: pytest_socket.egg-info/
@poetry run pytest

testrelease: build
dist: clean poetry.lock
@poetry build

testrelease: dist
# Requires a `[pypitest]` section in ~/.pypirc
@twine upload -r pypitest dist/*

release: build
release: dist
@twine upload dist/*
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ or for whole test run
Contributing
------------
Contributions are very welcome. Tests can be run with `tox`_, please ensure
Contributions are very welcome. Tests can be run with `pytest`_, please ensure
the coverage at least stays the same before you submit a pull request.

License
Expand Down
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[tool.poetry]
name = "pytest-socket"
version = "0.3.3"
description = "Pytest Plugin to disable socket calls during tests"
authors = ["Mike Fiedler <miketheman@gmail.com>"]
license = "MIT"
readme = "README.rst"
homepage = "https://pypi.org/project/pytest-socket/"
repository = "https://github.com/miketheman/pytest-socket"
include = [
"LICENSE",
"README.rst",
]
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: Pytest",
"Intended Audience :: Developers",
"Topic :: Software Development :: Testing",
"Programming Language :: Python",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
]

[tool.poetry.dependencies]
python = "^3.5"
pytest = ">=3.6.3"

[tool.poetry.dev-dependencies]
pytest = "^5.4"
pytest-cov = "^2.8.1"
pytest-httpbin = "^1.0"

[tool.poetry.plugins.pytest11]
socket = 'pytest_socket'

[tool.poetry.urls]
"Bug Tracker" = "https://github.com/miketheman/pytest-socket/issues"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
addopts =
--cov
--cov-report=term
46 changes: 0 additions & 46 deletions setup.py

This file was deleted.

35 changes: 0 additions & 35 deletions tox.ini

This file was deleted.

0 comments on commit 0aee845

Please sign in to comment.