Skip to content

Commit

Permalink
Replace distutils.core by setuptools and add unittest2 as test depend…
Browse files Browse the repository at this point in the history
…ency for Python < 2.7.
  • Loading branch information
bdrung committed Mar 26, 2014
1 parent e2c3c9f commit d86a78f
Showing 1 changed file with 6 additions and 37 deletions.
43 changes: 6 additions & 37 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,12 @@
import sys
import os
import os.path
from distutils.core import setup, Command
from setuptools import setup
import appdirs

requires_list = []
try:
import unittest2 as unittest
except ImportError:
import unittest
else:
if sys.version_info <= (2, 6):
requires_list.append("unittest2")


class RunTests(Command):
"""New setup.py command to run all tests for the package.
"""
description = "run all tests for the package"

user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
test_modules = ["test.%s" % filename.replace('.py', '')
for filename in os.listdir('test')
if filename.endswith('.py') and filename.startswith('test_')]
for mod in test_modules:
__import__(mod)

suite = unittest.TestSuite()
for mod in [sys.modules[modname] for modname in test_modules]:
suite.addTest(unittest.TestLoader().loadTestsFromModule(mod))
unittest.TextTestRunner(verbosity=2).run(suite)
tests_require = []
if sys.version_info < (2, 7):
tests_require.append("unittest2")


def read(fname):
Expand All @@ -53,7 +22,6 @@ def read(fname):
description='A small Python module for determining appropriate " + \
"platform-specific dirs, e.g. a "user data dir".',
long_description=read('README.rst') + '\n' + read('CHANGES.rst'),
cmdclass={'test': RunTests},
classifiers=[c.strip() for c in """
Development Status :: 4 - Beta
Intended Audience :: Developers
Expand All @@ -69,7 +37,8 @@ def read(fname):
Programming Language :: Python :: 3.2
Topic :: Software Development :: Libraries :: Python Modules
""".split('\n') if c.strip()],
requires=requires_list,
test_suite='test.test_api',
tests_require=tests_require,
keywords='application directory log cache user',
author='Trent Mick',
author_email='trentm@gmail.com',
Expand Down

0 comments on commit d86a78f

Please sign in to comment.