diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-08-14 17:39:34 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-08-14 17:39:51 +0200 |
commit | 7ee0e92cf1aa6ffb544cf6eadc8a6f0c0f205a7b (patch) | |
tree | 8c692a4532d88c17ebd13791a7b7793f1cc2e9cb /setup.py | |
parent | 9afe451c1deafda085d4a8c9d1c93ea95376ac95 (diff) | |
download | factory-boy-7ee0e92cf1aa6ffb544cf6eadc8a6f0c0f205a7b.tar factory-boy-7ee0e92cf1aa6ffb544cf6eadc8a6f0c0f205a7b.tar.gz |
Fix setup.py post-setuptools/distribute merge.
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 69 |
1 files changed, 12 insertions, 57 deletions
@@ -3,76 +3,31 @@ import os import re -import sys -from distutils.core import setup -from distutils import cmd -root = os.path.abspath(os.path.dirname(__file__)) +from setuptools import setup -def get_version(*module_dir_components): - version_re = re.compile(r"^__version__ = ['\"](.*)['\"]$") - module_root = os.path.join(root, *module_dir_components) - module_init = os.path.join(module_root, '__init__.py') - with open(module_init, 'r') as f: +root_dir = os.path.abspath(os.path.dirname(__file__)) + + +def get_version(package_name): + version_re = re.compile(r"^__version__ = [\"']([\w_.-]+)[\"']$") + package_components = package_name.split('.') + path_components = package_components + ['__init__.py'] + with open(os.path.join(root_dir, *path_components)) as f: for line in f: match = version_re.match(line[:-1]) if match: return match.groups()[0] return '0.1.0' -VERSION = get_version('factory') - - -class test(cmd.Command): - """Run the tests for this package.""" - command_name = 'test' - description = 'run the tests associated with the package' - - user_options = [ - ('test-suite=', None, "A test suite to run (defaults to 'tests')"), - ] - - def initialize_options(self): - self.test_runner = None - self.test_suite = None - - def finalize_options(self): - self.ensure_string('test_suite', 'tests') - - def run(self): - """Run the test suite.""" - try: - import unittest2 as unittest - except ImportError: - import unittest - - import logging - logger = logging.getLogger('factory') - logger.addHandler(logging.StreamHandler()) - - verbosity = self.verbose - if verbosity >= 2: - logger.setLevel(logging.DEBUG) - else: - logger.setLevel(logging.INFO) - - loader = unittest.TestLoader() - suite = unittest.TestSuite() - if self.test_suite == 'tests': - for test_module in loader.discover('.'): - suite.addTest(test_module) - else: - suite.addTest(loader.loadTestsFromName(self.test_suite)) - result = unittest.TextTestRunner(verbosity=verbosity).run(suite) - if not result.wasSuccessful(): - sys.exit(1) +PACKAGE = 'factory' setup( name='factory_boy', - version=VERSION, + version=get_version(PACKAGE), description="A verstile test fixtures replacement based on thoughtbot's factory_girl for Ruby.", author='Mark Sandstrom', author_email='mark@deliciouslynerdy.com', @@ -99,5 +54,5 @@ setup( 'Topic :: Software Development :: Testing', 'Topic :: Software Development :: Libraries :: Python Modules' ], - cmdclass={'test': test}, + test_suite='tests', ) |