Skip to content

Commit

Permalink
clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcountryman committed Sep 11, 2015
1 parent e88a2f2 commit 9d9bca8
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*.egg
*.egg-info
*.py[cod]
.cache/
.coverage
.tox
dist
build
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: python
install:
- pip install tox
script:
- tox
python:
- 2.7
- 3.3
- 3.4
script: python setup.py test
35 changes: 30 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,46 @@
* `development version
<https://github.com/maxcountryman/flake8-single-quotes>`_
'''
import sys

from setuptools import setup
from setuptools import find_packages, setup
from setuptools.command.test import test as TestCommand

import flake8_single_quotes

setup_requires = ['pytest', 'tox']
install_requires = ['setuptools', 'tox']
tests_requires = ['pytest-cov', 'pytest-cache']


class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = ['--strict',
'--verbose',
'--tb=long',
'--cov', 'flake8_single_quotes.py',
'--cov-report', 'term-missing', 'tests']
self.test_suite = True

def run_tests(self):
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)


ext_checker_str = 'flake8_single_quotes = flake8_single_quotes:QuoteChecker'

setup(name='flake8-single-quotes',
author='Max Countryman',
author_email='[email protected]',
version=flake8_single_quotes.__version__,
install_requires=['setuptools'],
url='http://github.com/maxcountryman/flake8-single-quotes/',
long_description=__doc__,
description='A Flake8 extension to enforce single-quotes.',
long_description=__doc__,
py_modules=['flake8_single_quotes'],
test_suite='test',
include_package_data=True,
entry_points={'flake8.extension': [ext_checker_str]},
packages=find_packages(exclude=['tests']),
classifiers=['Development Status :: 4 - Beta',
'Environment :: Console',
'Intended Audience :: Developers',
Expand All @@ -37,4 +57,9 @@
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Topic :: Software Development :: Quality Assurance'],
cmdclass={'test': PyTest},
setup_requires=setup_requires,
install_requires=install_requires,
tests_require=tests_requires,
extras_require={'test': tests_requires},
zip_safe=False)
33 changes: 0 additions & 33 deletions test/test_checks.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions tests/test_checks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os

import flake8_single_quotes as fsq


def test_get_noqa_lines():
with open('tests/data/no_qa.py') as f:
lines = f.readlines()
assert fsq.get_noqa_lines(lines) == [2]


def test_wrapped():
with open('tests/data/wrapped.py') as f:
lines = f.readlines()
assert list(fsq.get_double_quotes_errors(lines)) == []


def test_doubles():
with open('tests/data/doubles.py') as f:
lines = f.readlines()
expected = [{'col': 24,
'line': 1,
'message': 'Q000 Strings should use single quotes.'}]
assert list(fsq.get_double_quotes_errors(lines)) == expected


def test_noqa_doubles():
abspath = os.path.abspath('tests/data/doubles_noqa.py')
checker = fsq.QuoteChecker(None, abspath)
assert list(checker.run()) == []

0 comments on commit 9d9bca8

Please sign in to comment.