Skip to content

Commit

Permalink
Merge pull request #4 from davidszotten/coverage4
Browse files Browse the repository at this point in the history
compat for coverage 4
  • Loading branch information
davidszotten authored Sep 21, 2016
2 parents 2f7759e + a967c99 commit 08b4528
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "pypy"
- "pypy3"

Expand Down
9 changes: 9 additions & 0 deletions pytest_cagoule/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys


PY3 = sys.version_info[0] == 3

if PY3:
string_types = str,
else:
string_types = basestring, # noqa: F821
4 changes: 2 additions & 2 deletions pytest_cagoule/git_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import subprocess

import six
from .compat import string_types

NULL = object()

Expand Down Expand Up @@ -42,7 +42,7 @@ def get_diff_changes(diff):

if marker is NULL:
filename = None
if isinstance(marker, six.string_types):
if isinstance(marker, string_types):
filename = marker
elif isinstance(marker, dict):
del_start = int(marker['del_start'])
Expand Down
9 changes: 4 additions & 5 deletions pytest_cagoule/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from itertools import count

from coverage import coverage
import six

from .db import get_connection
from .git_parser import get_changes
Expand Down Expand Up @@ -74,7 +73,7 @@ def setup_db(self):
""")

def filename_values(self, cov_data):
for filename, lines in six.iteritems(cov_data.lines):
for filename in cov_data.measured_files():
file_id = filename_map[filename]
yield file_id, filename

Expand All @@ -84,9 +83,9 @@ def nodeid_values(self, nodeid):

def coverage_values(self, nodeid, cov_data):
nodeid_id = nodeid_map[nodeid]
for filename, lines in six.iteritems(cov_data.lines):
for filename in cov_data.measured_files():
file_id = filename_map[filename]
for line in lines:
for line in cov_data.lines(filename):
yield nodeid_id, file_id, line

def write_results(self, nodeid, cov_data):
Expand Down Expand Up @@ -124,7 +123,7 @@ def pytest_runtest_teardown(self, item):
return
cov.stop()
self.tracing = False
cov._harvest_data()
cov.save()

self.write_results(item.nodeid, cov.data)

Expand Down
5 changes: 2 additions & 3 deletions pytest_cagoule/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import os
import re

import six

from .compat import string_types
from .db import get_connection, db_exists

spec_re = re.compile(
Expand Down Expand Up @@ -58,7 +57,7 @@ def get_query(specs):

def get_spec_filter(spec):
# TODO: find where to best do this
if isinstance(spec, six.string_types):
if isinstance(spec, string_types):
spec = parse_spec(spec)

filename, start_line, end_line = spec
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="pytest-cagoule",
version='0.2.0',
version='0.3.0',

description='Pytest plugin to only run tests affected by changes',
long_description=long_description,
Expand All @@ -20,9 +20,8 @@
packages=['pytest_cagoule'],

install_requires=[
'coverage',
'coverage>=4',
'pytest',
'six',
],

entry_points={
Expand Down

0 comments on commit 08b4528

Please sign in to comment.