提交 901703c0 authored 作者: Mohammad Pezeshki's avatar Mohammad Pezeshki

nose imports moved to functions needing nose

上级 ecfe7453
...@@ -3,12 +3,7 @@ import os ...@@ -3,12 +3,7 @@ import os
import unittest import unittest
import sys import sys
from nose.config import Config
from nose.plugins.manager import PluginManager
import nose.plugins.builtin
from numpy.testing.nosetester import NoseTester from numpy.testing.nosetester import NoseTester
from numpy.testing.noseclasses import KnownFailure, NumpyTestProgram
# This class contains code adapted from NumPy, # This class contains code adapted from NumPy,
...@@ -56,6 +51,7 @@ class TheanoNoseTester(NoseTester): ...@@ -56,6 +51,7 @@ class TheanoNoseTester(NoseTester):
Takes the same arguments as `test`. Takes the same arguments as `test`.
""" """
import nose.plugins.builtin
# compile argv # compile argv
argv = self._test_argv(verbose, extra_argv) argv = self._test_argv(verbose, extra_argv)
...@@ -72,6 +68,7 @@ class TheanoNoseTester(NoseTester): ...@@ -72,6 +68,7 @@ class TheanoNoseTester(NoseTester):
# construct list of plugins # construct list of plugins
plugins = [] plugins = []
if knownfailure: if knownfailure:
from numpy.testing.noseclasses import KnownFailure
plugins.append(KnownFailure()) plugins.append(KnownFailure())
plugins += [p() for p in nose.plugins.builtin.plugins] plugins += [p() for p in nose.plugins.builtin.plugins]
...@@ -107,6 +104,9 @@ class TheanoNoseTester(NoseTester): ...@@ -107,6 +104,9 @@ class TheanoNoseTester(NoseTester):
:returns: Returns the result of running the tests as a :returns: Returns the result of running the tests as a
``nose.result.TextTestResult`` object. ``nose.result.TextTestResult`` object.
""" """
from nose.config import Config
from nose.plugins.manager import PluginManager
from numpy.testing.noseclasses import NumpyTestProgram
# Many Theano tests suppose device=cpu, so we need to raise an # Many Theano tests suppose device=cpu, so we need to raise an
# error if device==gpu. # error if device==gpu.
if not os.path.exists('theano/__init__.py'): if not os.path.exists('theano/__init__.py'):
......
...@@ -19,13 +19,6 @@ import numpy ...@@ -19,13 +19,6 @@ import numpy
import theano import theano
import theano.tensor as T import theano.tensor as T
from theano.configparser import config, AddConfigVar, StrParam from theano.configparser import config, AddConfigVar, StrParam
try:
from nose.plugins.skip import SkipTest
except ImportError:
class SkipTest(Exception):
"""
Skip this test
"""
_logger = logging.getLogger("theano.tests.unittest_tools") _logger = logging.getLogger("theano.tests.unittest_tools")
...@@ -137,6 +130,13 @@ class TestOptimizationMixin(object): ...@@ -137,6 +130,13 @@ class TestOptimizationMixin(object):
return self.assertFunctionContainsClass(f, op, min=N, max=N) return self.assertFunctionContainsClass(f, op, min=N, max=N)
def SkipTest(self, msg='Skip this test'): def SkipTest(self, msg='Skip this test'):
try:
from nose.plugins.skip import SkipTest
except ImportError:
class SkipTest(Exception):
"""
Skip this test
"""
raise SkipTest(msg) raise SkipTest(msg)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论