mirror of
https://github.com/httpie/cli.git
synced 2024-11-24 16:53:35 +01:00
Use a more modern approach to run tests (#1089)
Running tests through `python setup.py test` is deprecated: > WARNING: Testing via this command is deprecated and will be removed > in a future version. Users looking for a generic test entry point > independent of test runner are encouraged to use tox. I am not in favor of moving back to `tox`, we should simply run tests using `python -m pytest` (or `make test`) and that's it. A new extra was added, `dev`, to install development requirements: $ python -m pip install --upgrade --editable '.[dev]'
This commit is contained in:
parent
da03a0656e
commit
9857693ebf
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -30,5 +30,5 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- run: python -m pip install --upgrade pip setuptools wheel
|
||||
- run: python -m pip install --upgrade --editable .
|
||||
- run: python setup.py test
|
||||
- run: python -m pip install --upgrade '.[dev]'
|
||||
- run: python -m pytest --verbose ./httpie ./tests
|
||||
|
@ -193,7 +193,7 @@ Install HTTPie in editable mode with all the dependencies:
|
||||
|
||||
.. code-block:: powershell
|
||||
|
||||
python -m pip install --upgrade --editable . -r requirements-dev.txt
|
||||
python -m pip install --upgrade --editable '.[dev]'
|
||||
|
||||
You should now see ``(httpie)`` next to your shell prompt, and
|
||||
the ``http`` command should point to your development copy:
|
||||
|
5
Makefile
5
Makefile
@ -6,7 +6,6 @@
|
||||
|
||||
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
VERSION=$(shell grep __version__ httpie/__init__.py)
|
||||
REQUIREMENTS=requirements-dev.txt
|
||||
H1="\n\n\033[0;32m\#\#\# "
|
||||
H1END=" \#\#\# \033[0m\n"
|
||||
|
||||
@ -28,7 +27,7 @@ all: uninstall-httpie install test
|
||||
|
||||
install: venv
|
||||
@echo $(H1)Installing dev requirements$(H1END)
|
||||
$(VENV_PIP) install --upgrade -r $(REQUIREMENTS)
|
||||
$(VENV_PIP) install --upgrade --editable '.[dev]'
|
||||
|
||||
@echo $(H1)Installing HTTPie$(H1END)
|
||||
$(VENV_PIP) install --upgrade --editable .
|
||||
@ -123,7 +122,7 @@ pycodestyle: codestyle
|
||||
|
||||
codestyle:
|
||||
@echo $(H1)Running flake8$(H1END)
|
||||
@[ -f $(VENV_BIN)/flake8 ] || $(VENV_PIP) install --upgrade -r $(REQUIREMENTS)
|
||||
@[ -f $(VENV_BIN)/flake8 ] || $(VENV_PIP) install --upgrade --editable '.[dev]'
|
||||
$(VENV_BIN)/flake8 httpie/ tests/ extras/ *.py
|
||||
@echo
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
flake8
|
||||
flake8-comprehensions
|
||||
flake8-deprecated
|
||||
flake8-mutable
|
||||
flake8-tuple
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-httpbin>=0.0.6
|
||||
docutils
|
||||
wheel
|
||||
twine
|
44
setup.py
44
setup.py
@ -4,39 +4,26 @@ import sys
|
||||
import codecs
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
from setuptools.command.test import test as TestCommand
|
||||
|
||||
import httpie
|
||||
|
||||
|
||||
class PyTest(TestCommand):
|
||||
"""
|
||||
Running `$ python setup.py test' simply installs minimal requirements
|
||||
and runs the tests with no fancy stuff like parallel execution.
|
||||
|
||||
"""
|
||||
|
||||
def finalize_options(self):
|
||||
TestCommand.finalize_options(self)
|
||||
self.test_args = [
|
||||
'--doctest-modules',
|
||||
'--verbose',
|
||||
'./httpie',
|
||||
'./tests',
|
||||
]
|
||||
self.test_suite = True
|
||||
|
||||
def run_tests(self):
|
||||
import pytest
|
||||
sys.exit(pytest.main(self.test_args))
|
||||
|
||||
|
||||
# Note: keep requirements here to ease distributions packaging
|
||||
tests_require = [
|
||||
'pytest-httpbin',
|
||||
'docutils',
|
||||
'pytest',
|
||||
'pytest-httpbin>=0.0.6',
|
||||
]
|
||||
dev_require = [
|
||||
*tests_require,
|
||||
'flake8',
|
||||
'flake8-comprehensions',
|
||||
'flake8-deprecated',
|
||||
'flake8-mutable',
|
||||
'flake8-tuple',
|
||||
'pytest-cov',
|
||||
'twine',
|
||||
'wheel',
|
||||
]
|
||||
|
||||
|
||||
install_requires = [
|
||||
'requests[socks]>=2.22.0',
|
||||
'Pygments>=2.5.2',
|
||||
@ -59,6 +46,7 @@ if 'bdist_wheel' not in sys.argv:
|
||||
|
||||
# bdist_wheel
|
||||
extras_require = {
|
||||
'dev': dev_require,
|
||||
'test': tests_require,
|
||||
# https://wheel.readthedocs.io/en/latest/#defining-conditional-dependencies
|
||||
':sys_platform == "win32"': install_requires_win_only,
|
||||
@ -91,8 +79,6 @@ setup(
|
||||
python_requires='>=3.6',
|
||||
extras_require=extras_require,
|
||||
install_requires=install_requires,
|
||||
tests_require=tests_require,
|
||||
cmdclass={'test': PyTest},
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Programming Language :: Python',
|
||||
|
Loading…
Reference in New Issue
Block a user