This repository has been archived by the owner on Dec 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Robpol86/unicode_fix
Unicode fix.
- Loading branch information
Showing
13 changed files
with
102 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
#!/usr/bin/env python | ||
"""Setup script for the project.""" | ||
|
||
import atexit | ||
import codecs | ||
import os | ||
import re | ||
import subprocess | ||
import sys | ||
from distutils.spawn import find_executable | ||
|
||
import setuptools | ||
from setuptools.command.test import test | ||
|
||
_PACKAGES = lambda: [os.path.join(r, s) for r, d, _ in os.walk(NAME_FILE) for s in d if s != '__pycache__'] | ||
_VERSION_RE = re.compile(r"^__(version|author|license)__ = '([\w\.@]+)'$", re.MULTILINE) | ||
|
@@ -38,19 +33,12 @@ | |
NAME = 'flake8-pep257' | ||
NAME_FILE = NAME.replace('-', '_') | ||
PACKAGE = False | ||
REQUIRES_INSTALL = ['flake8', 'pep257'] | ||
REQUIRES_TEST = ['pytest-cov'] | ||
REQUIRES_ALL = REQUIRES_INSTALL + REQUIRES_TEST | ||
VERSION_FILE = os.path.join(NAME_FILE, '__init__.py') if PACKAGE else '{0}.py'.format(NAME_FILE) | ||
|
||
|
||
def _requires(path): | ||
"""Read requirements file.""" | ||
if not os.path.exists(os.path.join(HERE, path)): | ||
return list() | ||
file_handle = codecs.open(os.path.join(HERE, path), encoding='utf-8') | ||
requirements = [i.strip() for i in file_handle if i[0] != '-'] | ||
file_handle.close() | ||
return requirements | ||
|
||
|
||
def _safe_read(path, length): | ||
"""Read file contents.""" | ||
if not os.path.exists(os.path.join(HERE, path)): | ||
|
@@ -61,63 +49,17 @@ def _safe_read(path, length): | |
return contents | ||
|
||
|
||
class PyTest(test): | ||
"""Run tests with pytest.""" | ||
|
||
description = 'Run all tests.' | ||
user_options = [] | ||
CMD = 'test' | ||
TEST_ARGS = ['--cov-report', 'term-missing', '--cov', NAME_FILE, 'tests'] | ||
|
||
def finalize_options(self): | ||
"""Finalize options.""" | ||
overflow_args = sys.argv[sys.argv.index(self.CMD) + 1:] | ||
test.finalize_options(self) | ||
setattr(self, 'test_args', self.TEST_ARGS + overflow_args) | ||
setattr(self, 'test_suite', True) | ||
|
||
def run_tests(self): | ||
"""Run the tests.""" | ||
# Import here, cause outside the eggs aren't loaded. | ||
pytest = __import__('pytest') | ||
err_no = pytest.main(self.test_args) | ||
sys.exit(err_no) | ||
|
||
|
||
class PyTestPdb(PyTest): | ||
"""Run tests with pytest and drop to debugger on test failure/errors.""" | ||
|
||
_ipdb = 'ipdb' if sys.version_info[:2] > (2, 6) else 'pdb' | ||
description = 'Run all tests, drops to {0} upon unhandled exception.'.format(_ipdb) | ||
CMD = 'testpdb' | ||
TEST_ARGS = ['--{0}'.format(_ipdb), 'tests'] | ||
|
||
|
||
class PyTestCovWeb(PyTest): | ||
"""Run the tests and open a web browser (OS X only) showing coverage information.""" | ||
|
||
description = 'Generates HTML report on test coverage.' | ||
CMD = 'testcovweb' | ||
TEST_ARGS = ['--cov-report', 'html', '--cov', NAME_FILE, 'tests'] | ||
|
||
def run_tests(self): | ||
"""Run the tests and then open.""" | ||
if find_executable('open'): | ||
atexit.register(lambda: subprocess.call(['open', os.path.join(HERE, 'htmlcov', 'index.html')])) | ||
PyTest.run_tests(self) | ||
|
||
|
||
ALL_DATA = dict( | ||
author_email='[email protected]', | ||
classifiers=CLASSIFIERS, | ||
cmdclass={PyTest.CMD: PyTest, PyTestPdb.CMD: PyTestPdb, PyTestCovWeb.CMD: PyTestCovWeb}, | ||
description=DESCRIPTION, | ||
entry_points={'flake8.extension': 'D = flake8_pep257:Main'}, | ||
install_requires=_requires('requirements.txt'), | ||
install_requires=REQUIRES_INSTALL, | ||
keywords=KEYWORDS, | ||
long_description=_safe_read('README.rst', 15000), | ||
name=NAME, | ||
tests_require=_requires('requirements-test.txt'), | ||
requires=REQUIRES_INSTALL, | ||
tests_require=REQUIRES_TEST, | ||
url='https://github.com/Robpol86/{0}'.format(NAME), | ||
zip_safe=True, | ||
) | ||
|
@@ -126,7 +68,6 @@ def run_tests(self): | |
# noinspection PyTypeChecker | ||
ALL_DATA.update(dict(_VERSION_RE.findall(_safe_read(VERSION_FILE, 1500).replace('\r\n', '\n')))) | ||
ALL_DATA.update(dict(py_modules=[NAME_FILE]) if not PACKAGE else dict(packages=[NAME_FILE] + _PACKAGES())) | ||
ALL_DATA['requires'] = ALL_DATA['install_requires'] | ||
|
||
|
||
if __name__ == '__main__': | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.