test : optimized import statements

This commit is contained in:
alalazo 2016-03-03 09:17:49 +01:00
parent 21cd05aad5
commit 717bcb8624
31 changed files with 62 additions and 129 deletions

View File

@ -22,8 +22,6 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import unittest
import spack import spack
from spack.spec import Spec, CompilerSpec from spack.spec import Spec, CompilerSpec
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *

View File

@ -22,13 +22,13 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import unittest
import shutil
import os import os
import shutil
from tempfile import mkdtemp from tempfile import mkdtemp
from ordereddict_backport import OrderedDict
import spack import spack
import spack.config import spack.config
from ordereddict_backport import OrderedDict
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
# Some sample compiler config data # Some sample compiler config data

View File

@ -23,20 +23,15 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import os import os
import unittest
import shutil import shutil
import tempfile import tempfile
import unittest
from llnl.util.filesystem import * from llnl.util.filesystem import *
from spack.cmd.create import ConfigureGuesser from spack.cmd.create import ConfigureGuesser
from spack.stage import Stage from spack.stage import Stage
from spack.fetch_strategy import URLFetchStrategy
from spack.directory_layout import YamlDirectoryLayout
from spack.util.executable import which
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
from spack.test.mock_repo import MockArchive from spack.util.executable import which
class InstallTest(unittest.TestCase): class InstallTest(unittest.TestCase):

View File

@ -26,19 +26,18 @@
These tests check the database is functioning properly, These tests check the database is functioning properly,
both in memory and in its file both in memory and in its file
""" """
import tempfile
import shutil
import multiprocessing import multiprocessing
import shutil
from llnl.util.lock import * import tempfile
from llnl.util.filesystem import join_path
import spack import spack
from llnl.util.filesystem import join_path
from llnl.util.lock import *
from llnl.util.tty.colify import colify
from spack.database import Database from spack.database import Database
from spack.directory_layout import YamlDirectoryLayout from spack.directory_layout import YamlDirectoryLayout
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
from llnl.util.tty.colify import colify
def _print_ref_counts(): def _print_ref_counts():
"""Print out all ref counts for the graph used here, for debugging""" """Print out all ref counts for the graph used here, for debugging"""

View File

@ -25,20 +25,17 @@
"""\ """\
This test verifies that the Spack directory layout works properly. This test verifies that the Spack directory layout works properly.
""" """
import unittest
import tempfile
import shutil
import os import os
import shutil
from llnl.util.filesystem import * import tempfile
import spack import spack
from spack.spec import Spec from llnl.util.filesystem import *
from spack.repository import RepoPath
from spack.directory_layout import YamlDirectoryLayout from spack.directory_layout import YamlDirectoryLayout
from spack.repository import RepoPath
from spack.spec import Spec
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
# number of packages to test (to reduce test time) # number of packages to test (to reduce test time)
max_packages = 10 max_packages = 10

View File

@ -23,19 +23,12 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import os import os
import unittest
import shutil
import tempfile
from llnl.util.filesystem import *
import spack import spack
from spack.version import ver from llnl.util.filesystem import *
from spack.stage import Stage
from spack.util.executable import which
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
from spack.test.mock_repo import MockGitRepo from spack.test.mock_repo import MockGitRepo
from spack.version import ver
class GitFetchTest(MockPackagesTest): class GitFetchTest(MockPackagesTest):

View File

@ -23,16 +23,12 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import os import os
import unittest
from llnl.util.filesystem import *
import spack import spack
from spack.version import ver from spack.version import ver
from spack.stage import Stage
from spack.util.executable import which
from spack.test.mock_packages_test import *
from spack.test.mock_repo import MockHgRepo from spack.test.mock_repo import MockHgRepo
from llnl.util.filesystem import *
from spack.test.mock_packages_test import *
class HgFetchTest(MockPackagesTest): class HgFetchTest(MockPackagesTest):

View File

@ -22,18 +22,13 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import os
import unittest
import shutil import shutil
import tempfile import tempfile
from llnl.util.filesystem import *
import spack import spack
from spack.stage import Stage from llnl.util.filesystem import *
from spack.fetch_strategy import URLFetchStrategy, FetchStrategyComposite
from spack.directory_layout import YamlDirectoryLayout from spack.directory_layout import YamlDirectoryLayout
from spack.util.executable import which from spack.fetch_strategy import URLFetchStrategy, FetchStrategyComposite
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
from spack.test.mock_repo import MockArchive from spack.test.mock_repo import MockArchive

View File

@ -24,8 +24,6 @@
############################################################################## ##############################################################################
import os import os
import unittest import unittest
import shutil
import tempfile
from llnl.util.filesystem import * from llnl.util.filesystem import *
from llnl.util.link_tree import LinkTree from llnl.util.link_tree import LinkTree
@ -38,8 +36,7 @@ class LinkTreeTest(unittest.TestCase):
def setUp(self): def setUp(self):
self.stage = Stage('link-tree-test') self.stage = Stage('link-tree-test')
# FIXME : possibly this test needs to be refactored to avoid the explicit call to __enter__ and __exit__ self.stage.create()
self.stage.__enter__()
with working_dir(self.stage.path): with working_dir(self.stage.path):
touchp('source/1') touchp('source/1')
@ -54,7 +51,7 @@ def setUp(self):
self.link_tree = LinkTree(source_path) self.link_tree = LinkTree(source_path)
def tearDown(self): def tearDown(self):
self.stage.__exit__(None, None, None) self.stage.destroy()
def check_file_link(self, filename): def check_file_link(self, filename):

View File

@ -25,15 +25,13 @@
""" """
These tests ensure that our lock works correctly. These tests ensure that our lock works correctly.
""" """
import unittest
import os
import tempfile
import shutil import shutil
import tempfile
import unittest
from multiprocessing import Process from multiprocessing import Process
from llnl.util.lock import *
from llnl.util.filesystem import join_path, touch from llnl.util.filesystem import join_path, touch
from llnl.util.lock import *
from spack.util.multiproc import Barrier from spack.util.multiproc import Barrier
# This is the longest a failed test will take, as the barriers will # This is the longest a failed test will take, as the barriers will

View File

@ -28,13 +28,13 @@
This just tests whether the right args are getting passed to make. This just tests whether the right args are getting passed to make.
""" """
import os import os
import unittest
import tempfile
import shutil import shutil
import tempfile
import unittest
from llnl.util.filesystem import * from llnl.util.filesystem import *
from spack.util.environment import path_put_first
from spack.build_environment import MakeExecutable from spack.build_environment import MakeExecutable
from spack.util.environment import path_put_first
class MakeExecutableTest(unittest.TestCase): class MakeExecutableTest(unittest.TestCase):

View File

@ -23,11 +23,10 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import os import os
from filecmp import dircmp
import spack import spack
import spack.mirror import spack.mirror
from spack.util.compression import decompressor_for
from filecmp import dircmp
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
from spack.test.mock_repo import * from spack.test.mock_repo import *

View File

@ -22,17 +22,15 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import sys
import os import os
import shutil import shutil
import unittest
import tempfile import tempfile
from ordereddict_backport import OrderedDict import unittest
from llnl.util.filesystem import mkdirp
import spack import spack
import spack.config import spack.config
from llnl.util.filesystem import mkdirp
from ordereddict_backport import OrderedDict
from spack.repository import RepoPath from spack.repository import RepoPath
from spack.spec import Spec from spack.spec import Spec

View File

@ -26,13 +26,9 @@
import shutil import shutil
from llnl.util.filesystem import * from llnl.util.filesystem import *
import spack
from spack.version import ver
from spack.stage import Stage from spack.stage import Stage
from spack.util.executable import which from spack.util.executable import which
# #
# VCS Systems used by mock repo code. # VCS Systems used by mock repo code.
# #

View File

@ -25,14 +25,11 @@
""" """
Test for multi_method dispatch. Test for multi_method dispatch.
""" """
import unittest
import spack import spack
from spack.multimethod import * from spack.multimethod import *
from spack.version import *
from spack.spec import Spec
from spack.multimethod import when
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
from spack.version import *
class MultiMethodTest(MockPackagesTest): class MultiMethodTest(MockPackagesTest):

View File

@ -23,6 +23,7 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import unittest import unittest
from spack.util.naming import NamespaceTrie from spack.util.naming import NamespaceTrie

View File

@ -22,10 +22,8 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import unittest
import spack from spack.spec import Spec
from spack.spec import Spec, CompilerSpec
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
class ConcretizeTest(MockPackagesTest): class ConcretizeTest(MockPackagesTest):

View File

@ -22,14 +22,12 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import unittest
from llnl.util.filesystem import join_path
import spack import spack
from llnl.util.filesystem import join_path
from spack.repository import Repo from spack.repository import Repo
from spack.util.naming import mod_to_class
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *
from spack.util.naming import mod_to_class
class PackagesTest(MockPackagesTest): class PackagesTest(MockPackagesTest):
@ -77,30 +75,20 @@ def test_package_class_names(self):
# #
def test_import_package(self): def test_import_package(self):
import spack.pkg.builtin.mock.mpich pass
def test_import_package_as(self): def test_import_package_as(self):
import spack.pkg.builtin.mock.mpich as mp pass
def test_import_class_from_package(self): def test_import_class_from_package(self):
from spack.pkg.builtin.mock.mpich import Mpich pass
def test_import_module_from_package(self): def test_import_module_from_package(self):
from spack.pkg.builtin.mock import mpich pass
def test_import_namespace_container_modules(self): def test_import_namespace_container_modules(self):
import spack.pkg pass
import spack.pkg as p
from spack import pkg
import spack.pkg.builtin
import spack.pkg.builtin as b
from spack.pkg import builtin
import spack.pkg.builtin.mock
import spack.pkg.builtin.mock as m
from spack.pkg.builtin import mock

View File

@ -28,12 +28,11 @@
Spack was originally 2.7, but enough systems in 2014 are still using Spack was originally 2.7, but enough systems in 2014 are still using
2.6 on their frontend nodes that we need 2.6 to get adopted. 2.6 on their frontend nodes that we need 2.6 to get adopted.
""" """
import unittest
import os import os
import re import re
import unittest
import llnl.util.tty as tty import llnl.util.tty as tty
import pyqver2 import pyqver2
import spack import spack

View File

@ -31,8 +31,6 @@
import spack import spack
import spack.package import spack.package
from llnl.util.lang import list_modules
from spack.spec import Spec from spack.spec import Spec
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *

View File

@ -22,7 +22,6 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import unittest
from spack.spec import * from spack.spec import *
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *

View File

@ -23,9 +23,10 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import unittest import unittest
import spack.spec import spack.spec
from spack.spec import *
from spack.parse import Token from spack.parse import Token
from spack.spec import *
# Sample output for a complex lexing. # Sample output for a complex lexing.
complex_lex = [Token(ID, 'mvapich_foo'), complex_lex = [Token(ID, 'mvapich_foo'),

View File

@ -25,15 +25,13 @@
"""\ """\
Test that the Stage class works correctly. Test that the Stage class works correctly.
""" """
import unittest
import shutil
import os import os
import getpass import shutil
import unittest
from contextlib import * from contextlib import *
from llnl.util.filesystem import *
import spack import spack
from llnl.util.filesystem import *
from spack.stage import Stage from spack.stage import Stage
from spack.util.executable import which from spack.util.executable import which

View File

@ -24,18 +24,12 @@
############################################################################## ##############################################################################
import os import os
import re import re
import unittest
import shutil
import tempfile
from llnl.util.filesystem import *
import spack import spack
from spack.version import ver
from spack.stage import Stage
from spack.util.executable import which
from spack.test.mock_packages_test import *
from spack.test.mock_repo import svn, MockSvnRepo from spack.test.mock_repo import svn, MockSvnRepo
from spack.version import ver
from spack.test.mock_packages_test import *
from llnl.util.filesystem import *
class SvnFetchTest(MockPackagesTest): class SvnFetchTest(MockPackagesTest):

View File

@ -22,10 +22,10 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
from nose.plugins import Plugin
import os import os
from nose.plugins import Plugin
class Tally(Plugin): class Tally(Plugin):
name = 'tally' name = 'tally'

View File

@ -22,10 +22,11 @@
# along with this program; if not, write to the Free Software Foundation, # along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
############################################################################## ##############################################################################
import unittest
import itertools import itertools
import unittest
import spack import spack
test_install = __import__("spack.cmd.test-install", test_install = __import__("spack.cmd.test-install",
fromlist=["BuildId", "create_test_output", "TestResult"]) fromlist=["BuildId", "create_test_output", "TestResult"])

View File

@ -25,10 +25,7 @@
"""\ """\
Tests ability of spack to extrapolate URL versions from existing versions. Tests ability of spack to extrapolate URL versions from existing versions.
""" """
import spack
import spack.url as url import spack.url as url
from spack.spec import Spec
from spack.version import ver
from spack.test.mock_packages_test import * from spack.test.mock_packages_test import *

View File

@ -27,8 +27,8 @@
detection in Homebrew. detection in Homebrew.
""" """
import unittest import unittest
import spack.url as url import spack.url as url
from pprint import pprint
class UrlParseTest(unittest.TestCase): class UrlParseTest(unittest.TestCase):

View File

@ -27,7 +27,6 @@
""" """
import unittest import unittest
import spack
import spack.url as url import spack.url as url

View File

@ -28,6 +28,7 @@
where it makes sense. where it makes sense.
""" """
import unittest import unittest
from spack.version import * from spack.version import *

View File

@ -26,6 +26,7 @@
Test Spack's custom YAML format. Test Spack's custom YAML format.
""" """
import unittest import unittest
import spack.util.spack_yaml as syaml import spack.util.spack_yaml as syaml
test_file = """\ test_file = """\