summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore16
-rwxr-xr-xsetup.py69
-rw-r--r--tests/cyclic/foo.py4
3 files changed, 24 insertions, 65 deletions
diff --git a/.gitignore b/.gitignore
index 46b64e3..b4d25fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,15 @@
-*.pyc
+# Temporary files
.*.swp
+*.pyc
+*.pyo
+
+# Build-related files
+docs/_build/
.coverage
-MANIFEST
+.tox
+*.egg-info
+*.egg
build/
dist/
htmlcov/
-docs/_build
-docs/_static
-docs/_templates
-.tox
+MANIFEST
diff --git a/setup.py b/setup.py
index 42519ce..f8c1d3f 100755
--- a/setup.py
+++ b/setup.py
@@ -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',
)
diff --git a/tests/cyclic/foo.py b/tests/cyclic/foo.py
index 7f00f12..e584ed1 100644
--- a/tests/cyclic/foo.py
+++ b/tests/cyclic/foo.py
@@ -23,7 +23,7 @@
import factory
-from cyclic import bar
+from . import bar as bar_mod
class Foo(object):
def __init__(self, bar, x):
@@ -35,4 +35,4 @@ class FooFactory(factory.Factory):
FACTORY_FOR = Foo
x = 42
- bar = factory.SubFactory(bar.BarFactory)
+ bar = factory.SubFactory(bar_mod.BarFactory)