Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for click 8 #97

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ jobs:
- image: circleci/python:3.7
environment:
- TOXENV=py37-click6-coverage
py38-click7:
<<: *common
docker:
- image: circleci/python:3.8
environment:
- TOXENV=py38-click7-coverage
py38-click70:
<<: *common
docker:
- image: circleci/python:3.8
environment:
- TOXENV=py38-click70-coverage
checkqa:
<<: *common
docker:
Expand All @@ -99,6 +111,8 @@ workflows:
test:
jobs:
- py38
- py38-click7
- py38-click70
- py37-coveragepy5
- py37
- py37-click6
Expand Down
2 changes: 1 addition & 1 deletion covimerage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import re

import attr
from click.utils import string_types

from ._compat import string_types
from .coveragepy import CoverageData
from .logger import logger
from .utils import (
Expand Down
7 changes: 7 additions & 0 deletions covimerage/_compat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

try:
FileNotFoundError = FileNotFoundError
except NameError:
Expand All @@ -12,3 +14,8 @@
from shlex import quote as shell_quote
except ImportError:
from pipes import quote as shell_quote # noqa: F401

if sys.version_info < (3,):
string_types = (str, unicode) # noqa: F821
else:
string_types = str
4 changes: 1 addition & 3 deletions covimerage/utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import os
import re

from click.utils import string_types

from ._compat import shell_quote
from ._compat import shell_quote, string_types

# Empty (whitespace only), comments, continued, or `end` statements.
RE_NON_EXECED = re.compile(r'^\s*("|end|$)')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def run(self):
],
install_requires=[
'attrs>=16.1.0',
'click<7.1',
'click',
'coverage<5.0a6',
],
extras_require={
Expand Down
16 changes: 13 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
from covimerage.cli import get_version_message


def format_click_arg(name):
if click.__version__ < '7.0':
return '"{}"'.format(name)
elif click.__version__ < '7.1':
return '"{}..."'.format(name.upper())
else:
return "'{}...'".format(name.upper())


def test_dunder_main_run(capfd):
assert call([sys.executable, '-m', 'covimerage']) == 0
out, err = capfd.readouterr()
Expand Down Expand Up @@ -795,9 +804,10 @@ def test_run_forwards_sighup(devnull):

def test_run_cmd_requires_args(runner):
result = runner.invoke(cli.run, [])
assert 'Error: Missing argument "%s".' % (
'args' if click.__version__ < '7.0' else 'ARGS...',
) in result.output.splitlines()
assert (
'Error: Missing argument {}.'.format(format_click_arg('args'))
in result.output.splitlines()
)
assert result.exit_code == 2


Expand Down
11 changes: 6 additions & 5 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ def assert_output(result):
if click.__version__ < '7.0':
assert result.output.splitlines() == [
'Error: no such option: --nonexistingoption']
return
lines = result.output.splitlines()
assert lines[0] == 'Usage: main report [OPTIONS] [PROFILE_FILE]...'
if click.__version__ < '8.0':
assert lines[-1] == 'Error: no such option: --nonexistingoption'
else:
assert result.output.splitlines() == [
'Usage: main report [OPTIONS] [PROFILE_FILE]...',
'Try "main report -h" for help.',
'',
'Error: no such option: --nonexistingoption']
assert lines[-1] == 'Error: No such option: --nonexistingoption'

for level in ['error', 'warning', 'info', 'debug']:
result = runner.invoke(cli.main, [
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ changedir =
integration: {envtmpdir}
deps =
click6: click<7
click7: click<8
click70: click<7.1
coverage: pytest-cov
coveragepy4: coverage<5
coveragepy5: coverage==5.0a5
Expand Down