Skip to content
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
Empty file added .coveralls.yml
Empty file.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ python:
- "3.3"
- "3.4"
- "pypy"
sudo: false
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to use the new Docker infrastructure at Travis CI

install: pip install -r requirements.txt
script: nosetests
script:
- py.test -v --cov flake8diff --cov-report term-missing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gregarmer maybe do flake8 check here as well. after all this is flake8 repo so should probably adhere to flake8 as well...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I was looking at pytest-pep8, but I'll figure something out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use Makefile? I usually find that easiest. up to you though

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to avoid that if we can do it all here, might have have to do that anyway.

after_success:
- coveralls
2 changes: 1 addition & 1 deletion flake8diff/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class UnsupportedVCSError(BaseError):
"""

def __init__(self, vcs=None):
msg = '{0} VCS is not unsupported'
msg = '{0} VCS is not supported'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha. this made me laught 😃

self.message = msg.format(vcs)
super(UnsupportedVCSError, self).__init__()

Expand Down
8 changes: 3 additions & 5 deletions flake8diff/flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def __init__(self, commits, options=None):

self._should_include_violation = getattr(
self,
'_should_include_violation_{}'
'_should_include_violation_{0}'
''.format(self.options.get('strict_mode', 'only_lines'))
)

Expand All @@ -129,7 +129,7 @@ def get_vcs(self):
try:
vcs = vcs(self.commits, self.options)
except VCSNotInstalledError:
logger.error('Seems like {} is not installed'.format(vcs.name))
logger.error('Seems like {0} is not installed'.format(vcs.name))
else:
if vcs.is_used() and vcs.check():
return vcs
Expand Down Expand Up @@ -232,8 +232,6 @@ def process(self):
))

for line in violations:
print(SIMPLE_OUTPUT.format(
**self.get_color_kwargs(line)
))
print(SIMPLE_OUTPUT.format(**self.get_color_kwargs(line)))

return overall_violations == 0
4 changes: 2 additions & 2 deletions flake8diff/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
$ flake8-diff

"""
from __future__ import unicode_literals, print_function
from __future__ import print_function, unicode_literals

import argparse
import logging
import operator
Expand All @@ -24,7 +25,6 @@
from .flake8 import COLORS, STRICT_MODES, Flake8Diff
from .vcs import SUPPORTED_VCS


LOGGING_FORMAT = '%(asctime)-15s %(name)s %(levelname)s %(message)s'
ENVIRON_PREFIX = 'FLAKE8DIFF_{0}'
VERBOSITY_MAPPING = {
Expand Down
53 changes: 53 additions & 0 deletions flake8diff/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from __future__ import unicode_literals

from unittest import TestCase

from flake8diff.exceptions import (
Flake8NotInstalledError,
NotLocatableVCSError,
UnsupportedVCSError,
VCSNotInstalledError,
WrongVCSSpecified
)


class ExceptionsTestCase(TestCase):
def test_flake8_not_installed(self):
expected = "flake8 installation could not be found. Is it on $PATH?"

try:
raise Flake8NotInstalledError
except Flake8NotInstalledError as e:
self.assertEquals(str(e), expected)

def test_not_locatable_vcs(self):
expected = "VCS could not be determined automatically"

try:
raise NotLocatableVCSError
except NotLocatableVCSError as e:
self.assertEquals(str(e), expected)

def test_unsupported_vcs(self):
expected = "foo VCS is not supported"

try:
raise UnsupportedVCSError(vcs="foo")
except UnsupportedVCSError as e:
self.assertEquals(str(e), expected)

def test_vcs_not_installed(self):
expected = 'VCS "bar" installation could not be found. Is it on $PATH?'

try:
raise VCSNotInstalledError(vcs="bar")
except VCSNotInstalledError as e:
self.assertEquals(str(e), expected)

def test_wrong_vcs_specified(self):
expected = 'This is not a "baz" repository'

try:
raise WrongVCSSpecified(vcs="baz")
except WrongVCSSpecified as e:
self.assertEquals(str(e), expected)
8 changes: 8 additions & 0 deletions flake8diff/test_flake8.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from unittest import TestCase

from flake8diff import flake8


class Flake8DiffTestCase(TestCase):
def test_flake8diff(self):
f8d = flake8.Flake8Diff("", {})
11 changes: 11 additions & 0 deletions flake8diff/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""This test is primarily to trigger the argparse code in main.py
"""
from unittest import TestCase

from flake8diff import main # noqa


class MainTestCase(TestCase):
def test_main(self):
# using assertTrue() instead of assertIsNotNone() for py2.6 compat
self.assertTrue(main.LOGGING_FORMAT is not None)
19 changes: 19 additions & 0 deletions flake8diff/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys
import unittest
from subprocess import CalledProcessError

import pytest
import six
from flake8diff import utils


class UtilsTestCase(unittest.TestCase):
def test_execute_success(self):
pwd = utils._execute("pwd", strict=True)
self.assertTrue(pwd is not "")
self.assertTrue(isinstance(pwd, six.string_types))

@pytest.mark.skipif(sys.version_info < (2, 7), reason="Python >=2.7 needed")
def test_execute_failure(self):
with self.assertRaises(CalledProcessError):
utils._execute("doesnotexist", strict=True)
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Jinja2==2.7.1
MarkupSafe==0.18
Pygments==1.6
Sphinx==1.2.2
blessings==1.6
coveralls==0.5
docutils==0.11
flake8==2.4.1
six==1.9.0
sphinx-rtd-theme==0.1.6
pytest==2.7.2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe move these to requirements-dev.txt or something similar so that these are not installed when doing pip install flake8-diff?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually nevermind. we dont source this file in setup.py - https://github.com/dealertrack/flake8-diff/blob/master/setup.py#L19

pytest-cov==1.8.1
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[tox]
envlist = py26,py27,py34
[testenv]
deps = -rrequirements.txt
commands = py.test -v