diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | docs/development.rst | 2 | ||||
-rwxr-xr-x | setup.py | 57 | ||||
-rwxr-xr-x | smartypants | 1 | ||||
-rw-r--r-- | tests/test.py | 3 | ||||
-rw-r--r-- | tests/test_cli.py | 4 | ||||
-rw-r--r-- | tests/test_deprecated.py | 4 | ||||
-rw-r--r-- | tests/test_setup.py | 3 |
8 files changed, 69 insertions, 7 deletions
@@ -54,7 +54,7 @@ smartypants_command.py: smartypants # ============================================================================ -test: test_pep8 test_pyflakes test_test install_test +test: test_isort test_pep8 test_pyflakes test_test install_test test_%: @echo '=========================================================================================' diff --git a/docs/development.rst b/docs/development.rst index af82737..7becb8d 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -26,6 +26,7 @@ be able to run all tests with:: It will test PEP8, pyflakes, unittest, and package installation:: + make test_isort make test_pep8 make test_pyflakes make test_test @@ -36,6 +37,7 @@ It will test PEP8, pyflakes, unittest, and package installation:: If ``make`` isn't available, ``setup.py`` can be used:: + python setup.py isort python setup.py pep8 python setup.py pyflakes python setup.py test @@ -3,9 +3,10 @@ # For detail license information, See COPYING from __future__ import print_function + +import sys from distutils.core import Command, setup from unittest import TestLoader, TextTestRunner -import sys try: from sphinx.setup_command import BuildDoc @@ -56,6 +57,59 @@ class cmd_test(Command): runner.run(tests) +class cmd_isort(Command): + + description = 'run isort' + user_options = [] + + def initialize_options(self): + + pass + + def finalize_options(self): + + pass + + def run(self): + + try: + import isort + except ImportError: + print(('Cannot import isort, you forgot to install?\n' + 'run `pip install isort` to install.'), file=sys.stderr) + sys.exit(1) + + from glob import glob + + print() + print('Options') + print('=======') + print() + print('Exclude:', EXCLUDE_SCRIPTS) + print() + + files = ['setup.py', CLI_script, module_file] + glob('tests/*.py') + + print('Results') + print('=======') + print() + + fails = 0 + for f in files: + # unfortunately, we have to do it twice + if isort.SortImports(f, check=True).incorrectly_sorted: + fails += 1 + print() + isort.SortImports(f, show_diff=True) + print() + + print() + print('Statistics') + print('==========') + print() + print('%d files failed to pass' % fails) + + class cmd_pep8(Command): description = 'run pep8' @@ -228,6 +282,7 @@ setup_d = dict( name=module_name, long_description=long_description, cmdclass={ + 'isort': cmd_isort, 'pep8': cmd_pep8, 'pyflakes': cmd_pyflakes, 'pylint': cmd_pylint, diff --git a/smartypants b/smartypants index c100d3d..d6f2f7b 100755 --- a/smartypants +++ b/smartypants @@ -65,6 +65,7 @@ Options """ from __future__ import print_function + import argparse import sys import warnings diff --git a/tests/test.py b/tests/test.py index 6b2c5da..c9451ac 100644 --- a/tests/test.py +++ b/tests/test.py @@ -6,7 +6,8 @@ import doctest import unittest import smartypants -from smartypants import Attr, smartypants as sp +from smartypants import smartypants as sp +from smartypants import Attr class SmartyPantsTestCase(unittest.TestCase): diff --git a/tests/test_cli.py b/tests/test_cli.py index 69b9e4d..263f319 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -2,11 +2,11 @@ # Licensed under the BSD License, for detailed license information, see COPYING from __future__ import unicode_literals + import os -from subprocess import Popen, PIPE import tempfile import unittest - +from subprocess import PIPE, Popen CLI_SCRIPT = './smartypants' diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py index 35c04d8..32e2fbd 100644 --- a/tests/test_deprecated.py +++ b/tests/test_deprecated.py @@ -6,7 +6,9 @@ import unittest import warnings import smartypants as sps -from smartypants import Attr, smartypants as sp, smartyPants as sP +from smartypants import smartypants as sp +from smartypants import smartyPants as sP +from smartypants import Attr class SmartyPantsDeprecatedTestCase(unittest.TestCase): diff --git a/tests/test_setup.py b/tests/test_setup.py index ed6a390..e5eb654 100644 --- a/tests/test_setup.py +++ b/tests/test_setup.py @@ -1,9 +1,10 @@ # Copyright (c) 2013 Yu-Jie Lin # Licensed under the BSD License, for detailed license information, see COPYING -from docutils.core import publish_string import unittest +from docutils.core import publish_string + class SetupTestCase(unittest.TestCase): |