Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Test running improvements #9

Merged
merged 2 commits into from

2 participants

@kmike

Tests can be run under python 2.6 (by using optional unittest2), tox config for testing under different pythons, explicit python version requirements (factory_boy works with python 2.6 and 2.7); ./setup.py test returns proper error code in case of test failure.

@kmike kmike Test running improvements: tests can be run under python 2.6 (by usin…
…g optional unittest2), tox config for testing under different pythons, explicit python version requirements (factory_boy works with python 2.6 and 2.7); ./setup.py test returns proper error code in case of test failure.
af00973
setup.py
@@ -34,7 +39,9 @@ def run(self):
suite = unittest.TestLoader().loadTestsFromName(self.test_suite)
- unittest.TextTestRunner(verbosity=verbosity).run(suite)
+ result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
+ if (not result.wasSuccessful()):
@rbarrois Owner

No need to add brackets here

@kmike
kmike added a note

agree.

@kmike
kmike added a note

By the way, isn't it better to switch to nose and remove custom ./setup.py test ? This way proper return values & code coverage will be given for free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@rbarrois rbarrois commented on the diff
@@ -0,0 +1,11 @@
+[tox]
@rbarrois Owner

Could you add a short comment pointing to tox docs (http://tox.readthedocs.org/en/latest/) for users unfamiliar with tox?

@kmike
kmike added a note

How do you think, what is the best place for this? I can't find any development docs for factory_boy (how to contribute, how to run tests). Travis CI is also undocumented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@kmike

Changes from this pull request are also in #10

@rbarrois rbarrois merged commit 223c31c into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 10, 2012
  1. @kmike

    Test running improvements: tests can be run under python 2.6 (by usin…

    kmike authored
    …g optional unittest2), tox config for testing under different pythons, explicit python version requirements (factory_boy works with python 2.6 and 2.7); ./setup.py test returns proper error code in case of test failure.
  2. @kmike

    2 bytes less to download

    kmike authored
This page is out of date. Refresh to see the latest.
View
1  .gitignore
@@ -8,3 +8,4 @@ htmlcov/
docs/_build
docs/_static
docs/_templates
+.tox
View
16 setup.py 100644 → 100755
@@ -1,6 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
+import sys
from distutils.core import setup
from distutils import cmd
@@ -26,7 +27,11 @@ def finalize_options(self):
def run(self):
"""Run the test suite."""
- import unittest
+ try:
+ import unittest2 as unittest
+ except ImportError:
+ import unittest
+
if self.verbose:
verbosity=1
else:
@@ -34,7 +39,9 @@ def run(self):
suite = unittest.TestLoader().loadTestsFromName(self.test_suite)
- unittest.TextTestRunner(verbosity=verbosity).run(suite)
+ result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
+ if not result.wasSuccessful():
+ sys.exit(1)
setup(
@@ -45,7 +52,7 @@ def run(self):
author_email='mark@deliciouslynerdy.com',
maintainer='Raphaël Barrois',
maintainer_email='raphael.barrois@polytechnique.org',
- url='http://github.com/rbarrois/factory_boy',
+ url='https://github.com/rbarrois/factory_boy',
keywords=['factory_boy', 'factory', 'fixtures'],
packages=['factory'],
license='MIT',
@@ -56,6 +63,9 @@ def run(self):
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
+ 'Programming Language :: Python :: 2',
+ 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
'Topic :: Software Development :: Testing',
'Topic :: Software Development :: Libraries :: Python Modules'
],
View
6 tests/test_base.py
@@ -20,7 +20,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-import unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
import warnings
from factory import base
View
5 tests/test_containers.py
@@ -20,7 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-import unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
from factory import base
from factory import containers
View
5 tests/test_declarations.py
@@ -20,7 +20,10 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-import unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
from factory.declarations import deepgetattr, OrderedDeclaration, Sequence
View
5 tests/test_using.py
@@ -20,7 +20,10 @@
# THE SOFTWARE.
"""Tests using factory."""
-import unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
import factory
View
5 tests/test_utils.py
@@ -21,7 +21,10 @@
# THE SOFTWARE.
-import unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
from factory import utils
View
11 tox.ini
@@ -0,0 +1,11 @@
+[tox]
@rbarrois Owner

Could you add a short comment pointing to tox docs (http://tox.readthedocs.org/en/latest/) for users unfamiliar with tox?

@kmike
kmike added a note

How do you think, what is the best place for this? I can't find any development docs for factory_boy (how to contribute, how to run tests). Travis CI is also undocumented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+envlist = py26,py27,pypy
+
+[testenv]
+commands=
+ python setup.py test
+
+[testenv:py26]
+
+deps=
+ unittest2
Something went wrong with that request. Please try again.