[Scipy-svn] r4424 - trunk/scipy/testing
scipy-svn@scip...
scipy-svn@scip...
Wed Jun 11 05:47:06 CDT 2008
Author: rkern
Date: 2008-06-11 05:47:02 -0500 (Wed, 11 Jun 2008)
New Revision: 4424
Removed:
trunk/scipy/testing/nulltester.py
Modified:
trunk/scipy/testing/__init__.py
trunk/scipy/testing/decorators.py
trunk/scipy/testing/nosetester.py
trunk/scipy/testing/pkgtester.py
Log:
Use local imports to avoid importing nose until tests are actually requested. This speeds up the load-time of scipy.
Modified: trunk/scipy/testing/__init__.py
===================================================================
--- trunk/scipy/testing/__init__.py 2008-06-10 06:35:31 UTC (rev 4423)
+++ trunk/scipy/testing/__init__.py 2008-06-11 10:47:02 UTC (rev 4424)
@@ -8,11 +8,6 @@
import unittest
from unittest import TestCase
-try:
- import nose
-except ImportError:
- pass
-
import decorators as dec
from numpy.testing.utils import *
from utils import *
Modified: trunk/scipy/testing/decorators.py
===================================================================
--- trunk/scipy/testing/decorators.py 2008-06-10 06:35:31 UTC (rev 4423)
+++ trunk/scipy/testing/decorators.py 2008-06-11 10:47:02 UTC (rev 4424)
@@ -10,11 +10,6 @@
"""
-try:
- import nose
-except ImportError:
- pass
-
def slow(t):
"""Labels a test as 'slow'.
@@ -76,6 +71,9 @@
if msg is None:
msg = 'Test skipped due to test condition'
def skip_decorator(f):
+ # Local import to avoid a hard nose dependency and only incur the import
+ # time overhead at actual test-time.
+ import nose
def skipper(*args, **kwargs):
if skip_condition:
raise nose.SkipTest, msg
@@ -87,6 +85,9 @@
def skipknownfailure(f):
''' Decorator to raise SkipTest for test known to fail
'''
+ # Local import to avoid a hard nose dependency and only incur the import
+ # time overhead at actual test-time.
+ import nose
def skipper(*args, **kwargs):
raise nose.SkipTest, 'This test is known to fail'
return nose.tools.make_decorator(f)(skipper)
Modified: trunk/scipy/testing/nosetester.py
===================================================================
--- trunk/scipy/testing/nosetester.py 2008-06-10 06:35:31 UTC (rev 4423)
+++ trunk/scipy/testing/nosetester.py 2008-06-11 10:47:02 UTC (rev 4424)
@@ -7,8 +7,26 @@
import sys
import re
-import nose
+def import_nose():
+ """ Import nose only when needed.
+ """
+ fine_nose = True
+ try:
+ import nose
+ except ImportError:
+ fine_nose = False
+ else:
+ nose_version = nose.__versioninfo__
+ if nose_version[0] < 1 and nose_version[1] < 10:
+ fine_nose = False
+
+ if not fine_nose:
+ raise ImportError('Need nose >=0.10 for tests - see '
+ 'http://somethingaboutorange.com/mrl/projects/nose')
+
+ return nose
+
class NoseTester(object):
""" Nose test runner.
@@ -112,6 +130,7 @@
doctests : boolean
If True, run doctests in module, default False
'''
+ nose = import_nose()
argv = self._test_argv(label, verbose, extra_argv)
if doctests:
argv+=['--with-doctest']
@@ -122,6 +141,7 @@
''' Run benchmarks for module using nose
%(test_header)s'''
+ nose = import_nose()
argv = self._test_argv(label, verbose, extra_argv)
argv += ['--match', r'(?:^|[\\b_\\.%s-])[Bb]ench' % os.sep]
nose.run(argv=argv)
Deleted: trunk/scipy/testing/nulltester.py
===================================================================
--- trunk/scipy/testing/nulltester.py 2008-06-10 06:35:31 UTC (rev 4423)
+++ trunk/scipy/testing/nulltester.py 2008-06-11 10:47:02 UTC (rev 4424)
@@ -1,15 +0,0 @@
-''' Null tester to signal nose tests disabled
-
-Merely returns error reporting lack of nose package or version number
-below requirements.
-
-See pkgtester, nosetester modules
-
-'''
-
-class NullTester(object):
- def test(self, labels=None, *args, **kwargs):
- raise ImportError, \
- 'Need nose >=0.10 for tests - see %s' % \
- 'http://somethingaboutorange.com/mrl/projects/nose'
- bench = test
Modified: trunk/scipy/testing/pkgtester.py
===================================================================
--- trunk/scipy/testing/pkgtester.py 2008-06-10 06:35:31 UTC (rev 4423)
+++ trunk/scipy/testing/pkgtester.py 2008-06-11 10:47:02 UTC (rev 4424)
@@ -11,17 +11,4 @@
See nosetester module for test implementation
'''
-fine_nose = True
-try:
- import nose
-except ImportError:
- fine_nose = False
-else:
- nose_version = nose.__versioninfo__
- if nose_version[0] < 1 and nose_version[1] < 10:
- fine_nose = False
-
-if fine_nose:
- from scipy.testing.nosetester import NoseTester as Tester
-else:
- from scipy.testing.nulltester import NullTester as Tester
+from scipy.testing.nosetester import NoseTester as Tester
More information about the Scipy-svn
mailing list