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

fix version incompatibilites #218

Merged
merged 2 commits into from
Feb 12, 2020
Merged
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
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ repos:
args:
- --max-line-length=79
- --ignore-imports=yes
- -d broad-except
- -d fixme
- -d import-error
- -d invalid-name
Expand Down
2 changes: 1 addition & 1 deletion coveralls/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
3 changes: 1 addition & 2 deletions tests/api/configuration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import mock
import pytest
import sh
try:
import yaml
except ImportError:
Expand All @@ -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')
Expand Down
8 changes: 4 additions & 4 deletions tests/api/encoding_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import json
import logging
import os
import subprocess
import sys

import coverage
import pytest
import sh

from coveralls import Coveralls

Expand All @@ -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 = (
Expand All @@ -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() == []
Expand All @@ -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
Expand Down
36 changes: 24 additions & 12 deletions tests/api/reporter_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# coding: utf-8
# pylint: disable=no-self-use
import os
import subprocess
import unittest

import sh

from coveralls import Coveralls


Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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("<h1>This isn't python!</h1>", _out='extra.py')
with open('extra.py', 'w') as f:
f.write('print("Python rocks!")\n')
subprocess.call(['coverage', 'run', 'extra.py'], cwd=EXAMPLE_DIR)
with open('extra.py', 'w') as f:
f.write("<h1>This isn't python!</h1>\n")
assert Coveralls(repo_token='xxx').get_coverage() == []
6 changes: 4 additions & 2 deletions tests/api/wear_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import coverage
import mock
import pytest
import sh

import coveralls
from coveralls.api import log
Expand All @@ -23,7 +22,10 @@
@mock.patch('coveralls.api.requests')
class WearTest(unittest.TestCase):
def setUp(self):
sh.rm('-f', '.coverage')
try:
os.remove('.coverage')
except Exception:
pass

def test_wet_run(self, mock_requests):
mock_requests.post.return_value.json.return_value = EXPECTED
Expand Down
23 changes: 13 additions & 10 deletions tests/git_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import os
import re
import shutil
import subprocess
import tempfile
import unittest

import mock
import sh

import coveralls.git

Expand All @@ -25,15 +25,18 @@ class GitTest(unittest.TestCase):
def setUp(self):
self.dir = tempfile.mkdtemp()

sh.cd(self.dir)
sh.touch('README')

sh.git.init()
sh.git.config('user.name', '"{}"'.format(GIT_NAME))
sh.git.config('user.email', '"{}"'.format(GIT_EMAIL))
sh.git.add('README')
sh.git.commit('-m', GIT_COMMIT_MSG)
sh.git.remote('add', GIT_REMOTE, GIT_URL)
os.chdir(self.dir)
open('README', 'a').close()

subprocess.call(['git', 'init'], cwd=self.dir)
subprocess.call(['git', 'config', 'user.name',
'"{}"'.format(GIT_NAME)], cwd=self.dir)
subprocess.call(['git', 'config', 'user.email',
'"{}"'.format(GIT_EMAIL)], cwd=self.dir)
subprocess.call(['git', 'add', 'README'], cwd=self.dir)
subprocess.call(['git', 'commit', '-m', GIT_COMMIT_MSG], cwd=self.dir)
subprocess.call(['git', 'remote', 'add', GIT_REMOTE, GIT_URL],
cwd=self.dir)

def tearDown(self):
shutil.rmtree(self.dir)
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ usedevelop = true
deps =
mock
pytest
sh
pyyaml: PyYAML>=3.10
pyyaml: PyYAML>=3.10,<5.3
cov3: coverage<4.0
cov4: coverage>=4.0,<4.1
cov41: coverage>=4.1,<5.0
Expand Down