-
Couldn't load subscription status.
- Fork 8
Adding some test coverage #28
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,5 +6,9 @@ python: | |
| - "3.3" | ||
| - "3.4" | ||
| - "pypy" | ||
| sudo: false | ||
| install: pip install -r requirements.txt | ||
| script: nosetests | ||
| script: | ||
| - py.test -v --cov flake8diff --cov-report term-missing | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 I was looking at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe use There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ class UnsupportedVCSError(BaseError): | |
| """ | ||
|
|
||
| def __init__(self, vcs=None): | ||
| msg = '{0} VCS is not unsupported' | ||
| msg = '{0} VCS is not supported' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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__() | ||
|
|
||
|
|
||
| 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) |
| 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("", {}) |
| 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) |
| 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) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe move these to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually nevermind. we dont source this file in |
||
| pytest-cov==1.8.1 | ||
| 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 |
There was a problem hiding this comment.
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