diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c5b0a02d..c4ccb767 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,6 +31,7 @@ repos: args: - --max-line-length=79 - --ignore-imports=yes + - -d broad-except - -d fixme - -d import-error - -d invalid-name diff --git a/coveralls/api.py b/coveralls/api.py index 20598b9f..3778c877 100644 --- a/coveralls/api.py +++ b/coveralls/api.py @@ -95,7 +95,7 @@ def load_config_from_github(): pr = None if os.environ.get('GITHUB_REF', '').startswith('refs/pull/'): pr = os.environ.get('GITHUB_REF', '//').split('/')[2] - service_number += "-PR-{0}".format(pr) + service_number += '-PR-{0}'.format(pr) return 'github', service_number, pr @staticmethod diff --git a/setup.py b/setup.py index 63ff1602..58e57824 100644 --- a/setup.py +++ b/setup.py @@ -37,9 +37,11 @@ 'docopt>=0.6.1', 'requests>=1.0.0', ], - tests_require=['mock', 'pytest', 'sh>=1.08'], + tests_require=['mock', 'pytest'], extras_require={ - 'yaml': ['PyYAML>=3.10'], + # N.B. PyYAML 5.3 dropped support for Python 3.4... which we should + # also do... + 'yaml': ['PyYAML>=3.10,<5.3'], ':python_version < "3"': ['urllib3[secure]'], }, classifiers=[ diff --git a/tests/api/configuration_test.py b/tests/api/configuration_test.py index bd9f66a3..f046c7c7 100644 --- a/tests/api/configuration_test.py +++ b/tests/api/configuration_test.py @@ -7,7 +7,6 @@ import mock import pytest -import sh try: import yaml except ImportError: @@ -22,7 +21,7 @@ class Configuration(unittest.TestCase): def setUp(self): self.dir = tempfile.mkdtemp() - sh.cd(self.dir) + os.chdir(self.dir) with open('.coveralls.mock', 'w+') as fp: fp.write('repo_token: xxx\n') fp.write('service_name: jenkins\n') diff --git a/tests/api/encoding_test.py b/tests/api/encoding_test.py index 62cd35e0..feeaa943 100644 --- a/tests/api/encoding_test.py +++ b/tests/api/encoding_test.py @@ -2,11 +2,11 @@ import json import logging import os +import subprocess import sys import coverage import pytest -import sh from coveralls import Coveralls @@ -17,7 +17,7 @@ def test_non_unicode(): os.chdir(NONUNICODE_DIR) - sh.coverage('run', 'nonunicode.py') + subprocess.call(['coverage', 'run', 'nonunicode.py'], cwd=NONUNICODE_DIR) actual_json = json.dumps(Coveralls(repo_token='xxx').get_coverage()) expected_json_part = ( @@ -32,7 +32,7 @@ def test_non_unicode(): reason='coverage 4 not affected') def test_malformed_encoding_declaration(capfd): os.chdir(NONUNICODE_DIR) - sh.coverage('run', 'malformed.py') + subprocess.call(['coverage', 'run', 'malformed.py'], cwd=NONUNICODE_DIR) logging.getLogger('coveralls').addHandler(logging.StreamHandler()) assert Coveralls(repo_token='xxx').get_coverage() == [] @@ -46,7 +46,7 @@ def test_malformed_encoding_declaration(capfd): reason='coverage 3 fails') def test_malformed_encoding_declaration_py3_or_coverage4(): os.chdir(NONUNICODE_DIR) - sh.coverage('run', 'malformed.py') + subprocess.call(['coverage', 'run', 'malformed.py'], cwd=NONUNICODE_DIR) result = Coveralls(repo_token='xxx').get_coverage() assert len(result) == 1 diff --git a/tests/api/reporter_test.py b/tests/api/reporter_test.py index 2416ae5e..56100890 100644 --- a/tests/api/reporter_test.py +++ b/tests/api/reporter_test.py @@ -1,10 +1,9 @@ # coding: utf-8 # pylint: disable=no-self-use import os +import subprocess import unittest -import sh - from coveralls import Coveralls @@ -23,11 +22,17 @@ class ReporterTest(unittest.TestCase): def setUp(self): os.chdir(EXAMPLE_DIR) - sh.rm('-f', '.coverage') - sh.rm('-f', 'extra.py') + try: + os.remove('.coverage') + except Exception: + pass + try: + os.remove('extra.py') + except Exception: + pass def test_reporter(self): - sh.coverage('run', 'runtests.py') + subprocess.call(['coverage', 'run', 'runtests.py'], cwd=EXAMPLE_DIR) results = Coveralls(repo_token='xxx').get_coverage() assert len(results) == 2 @@ -59,7 +64,8 @@ def test_reporter(self): 'coverage': [None, 1, None, 1, 1, 1, 1]}) def test_reporter_with_branches(self): - sh.coverage('run', '--branch', 'runtests.py') + subprocess.call(['coverage', 'run', '--branch', 'runtests.py'], + cwd=EXAMPLE_DIR) results = Coveralls(repo_token='xxx').get_coverage() assert len(results) == 2 @@ -98,13 +104,19 @@ def test_reporter_with_branches(self): 'coverage': [None, 1, None, 1, 1, 1, 1]}) def test_missing_file(self): - sh.echo('print("Python rocks!")', _out='extra.py') - sh.coverage('run', 'extra.py') - sh.rm('-f', 'extra.py') + with open('extra.py', 'w') as f: + f.write('print("Python rocks!")\n') + subprocess.call(['coverage', 'run', 'extra.py'], cwd=EXAMPLE_DIR) + try: + os.remove('extra.py') + except Exception: + pass assert Coveralls(repo_token='xxx').get_coverage() == [] def test_not_python(self): - sh.echo('print("Python rocks!")', _out='extra.py') - sh.coverage('run', 'extra.py') - sh.echo("