提交 9eced720 authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Flake8 for main.py

上级 006f1de2
from __future__ import print_function from __future__ import print_function
import os, unittest, sys import os
import nose.plugins.builtin import unittest
import sys
from nose.config import Config from nose.config import Config
from nose.plugins.manager import PluginManager from nose.plugins.manager import PluginManager
from numpy.testing.nosetester import import_nose, NoseTester import nose.plugins.builtin
from numpy.testing.nosetester import NoseTester
from numpy.testing.noseclasses import KnownFailure, NumpyTestProgram from numpy.testing.noseclasses import KnownFailure, NumpyTestProgram
...@@ -31,7 +34,7 @@ class TheanoNoseTester(NoseTester): ...@@ -31,7 +34,7 @@ class TheanoNoseTester(NoseTester):
:type extra_argv: list :type extra_argv: list
:param extra_argv: List with any extra arguments to pass to nosetests. :param extra_argv: List with any extra arguments to pass to nosetests.
""" """
#self.package_path = os.path.abspath(self.package_path) # self.package_path = os.path.abspath(self.package_path)
argv = [__file__, self.package_path] argv = [__file__, self.package_path]
argv += ['--verbosity', str(verbose)] argv += ['--verbosity', str(verbose)]
if extra_argv: if extra_argv:
...@@ -39,8 +42,6 @@ class TheanoNoseTester(NoseTester): ...@@ -39,8 +42,6 @@ class TheanoNoseTester(NoseTester):
return argv return argv
def _show_system_info(self): def _show_system_info(self):
nose = import_nose()
import theano import theano
print("Theano version %s" % theano.__version__) print("Theano version %s" % theano.__version__)
theano_dir = os.path.dirname(theano.__file__) theano_dir = os.path.dirname(theano.__file__)
...@@ -49,22 +50,20 @@ class TheanoNoseTester(NoseTester): ...@@ -49,22 +50,20 @@ class TheanoNoseTester(NoseTester):
super(TheanoNoseTester, self)._show_system_info() super(TheanoNoseTester, self)._show_system_info()
def prepare_test_args(self, verbose=1, extra_argv=None, coverage=False, def prepare_test_args(self, verbose=1, extra_argv=None, coverage=False,
capture=True, knownfailure=True): capture=True, knownfailure=True):
""" """
Prepare arguments for the `test` method. Prepare arguments for the `test` method.
Takes the same arguments as `test`. Takes the same arguments as `test`.
""" """
# fail with nice error message if nose is not present
nose = import_nose()
# compile argv # compile argv
argv = self._test_argv(verbose, extra_argv) argv = self._test_argv(verbose, extra_argv)
# numpy way of doing coverage # numpy way of doing coverage
if coverage: if coverage:
argv += ['--cover-package=%s' % self.package_name, '--with-coverage', argv += ['--cover-package=%s' % self.package_name,
'--cover-tests', '--cover-inclusive', '--cover-erase'] '--with-coverage', '--cover-tests',
'--cover-inclusive', '--cover-erase']
# Capture output only if needed # Capture output only if needed
if not capture: if not capture:
...@@ -79,7 +78,7 @@ class TheanoNoseTester(NoseTester): ...@@ -79,7 +78,7 @@ class TheanoNoseTester(NoseTester):
return argv, plugins return argv, plugins
def test(self, verbose=1, extra_argv=None, coverage=False, capture=True, def test(self, verbose=1, extra_argv=None, coverage=False, capture=True,
knownfailure=True): knownfailure=True):
""" """
Run tests for module using nose. Run tests for module using nose.
...@@ -91,7 +90,8 @@ class TheanoNoseTester(NoseTester): ...@@ -91,7 +90,8 @@ class TheanoNoseTester(NoseTester):
:param extra_argv: List with any extra arguments to pass to nosetests. :param extra_argv: List with any extra arguments to pass to nosetests.
:type coverage: bool :type coverage: bool
:param coverage: If True, report coverage of Theano code. Default is False. :param coverage: If True, report coverage of Theano
code. Default is False.
:type capture: bool :type capture: bool
:param capture: If True, capture the standard output of the tests, like :param capture: If True, capture the standard output of the tests, like
...@@ -123,7 +123,7 @@ class TheanoNoseTester(NoseTester): ...@@ -123,7 +123,7 @@ class TheanoNoseTester(NoseTester):
"launch theano.test().")) "launch theano.test()."))
argv, plugins = self.prepare_test_args(verbose, extra_argv, coverage, argv, plugins = self.prepare_test_args(verbose, extra_argv, coverage,
capture, knownfailure) capture, knownfailure)
# The "plugins" keyword of NumpyTestProgram gets ignored if config is # The "plugins" keyword of NumpyTestProgram gets ignored if config is
# specified. Moreover, using "addplugins" instead can lead to strange # specified. Moreover, using "addplugins" instead can lead to strange
...@@ -134,8 +134,6 @@ class TheanoNoseTester(NoseTester): ...@@ -134,8 +134,6 @@ class TheanoNoseTester(NoseTester):
def main(modulename): def main(modulename):
debug = False
if 0: if 0:
unittest.main() unittest.main()
elif len(sys.argv) == 2 and sys.argv[1] == "--debug": elif len(sys.argv) == 2 and sys.argv[1] == "--debug":
......
...@@ -31,7 +31,6 @@ whitelist_flake8 = [ ...@@ -31,7 +31,6 @@ whitelist_flake8 = [
"tests/test_record.py", "tests/test_record.py",
"tests/__init__.py", "tests/__init__.py",
"tests/test_updates.py", "tests/test_updates.py",
"tests/main.py",
"tests/test_pickle_unpickle_theano_fn.py", "tests/test_pickle_unpickle_theano_fn.py",
"tests/test_determinism.py", "tests/test_determinism.py",
"tests/record.py", "tests/record.py",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论