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

nose imports moved to functions needing nose

上级 ecfe7453
......@@ -3,12 +3,7 @@ import os
import unittest
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.noseclasses import KnownFailure, NumpyTestProgram
# This class contains code adapted from NumPy,
......@@ -56,6 +51,7 @@ class TheanoNoseTester(NoseTester):
Takes the same arguments as `test`.
"""
import nose.plugins.builtin
# compile argv
argv = self._test_argv(verbose, extra_argv)
......@@ -72,6 +68,7 @@ class TheanoNoseTester(NoseTester):
# construct list of plugins
plugins = []
if knownfailure:
from numpy.testing.noseclasses import KnownFailure
plugins.append(KnownFailure())
plugins += [p() for p in nose.plugins.builtin.plugins]
......@@ -107,6 +104,9 @@ class TheanoNoseTester(NoseTester):
:returns: Returns the result of running the tests as a
``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
# error if device==gpu.
if not os.path.exists('theano/__init__.py'):
......
......@@ -19,13 +19,6 @@ import numpy
import theano
import theano.tensor as T
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")
......@@ -137,6 +130,13 @@ class TestOptimizationMixin(object):
return self.assertFunctionContainsClass(f, op, min=N, max=N)
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)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论