qa : flake8 issues
This commit is contained in:
parent
23006d1195
commit
5cfaa557d3
@ -158,6 +158,7 @@
|
||||
'nolink': nolink,
|
||||
}
|
||||
|
||||
|
||||
def colorize_spec(spec):
|
||||
"""Returns a spec colorized according to the colors specified in
|
||||
color_formats."""
|
||||
@ -1020,7 +1021,7 @@ def from_yaml(stream):
|
||||
"""
|
||||
try:
|
||||
yfile = yaml.load(stream)
|
||||
except MarkedYAMLError, e:
|
||||
except MarkedYAMLError as e:
|
||||
raise SpackYAMLError("error parsing YAML spec:", str(e))
|
||||
|
||||
nodes = yfile['spec']
|
||||
@ -1334,7 +1335,7 @@ def flat_dependencies_with_deptype(self, **kwargs):
|
||||
|
||||
return flat_deps
|
||||
|
||||
except UnsatisfiableSpecError, e:
|
||||
except UnsatisfiableSpecError as e:
|
||||
# Here, the DAG contains two instances of the same package
|
||||
# with inconsistent constraints. Users cannot produce
|
||||
# inconsistent specs like this on the command line: the
|
||||
@ -1369,7 +1370,7 @@ def _evaluate_dependency_conditions(self, name):
|
||||
dep = Spec(name)
|
||||
try:
|
||||
dep.constrain(dep_spec)
|
||||
except UnsatisfiableSpecError, e:
|
||||
except UnsatisfiableSpecError as e:
|
||||
e.message = ("Conflicting conditional dependencies on"
|
||||
"package %s for spec %s" % (self.name, self))
|
||||
raise e
|
||||
@ -1455,7 +1456,7 @@ def _merge_dependency(self, dep, deptypes, visited, spec_deps,
|
||||
try:
|
||||
changed |= spec_deps[dep.name].spec.constrain(dep)
|
||||
|
||||
except UnsatisfiableSpecError, e:
|
||||
except UnsatisfiableSpecError as e:
|
||||
e.message = "Invalid spec: '%s'. "
|
||||
e.message += "Package %s requires %s %s, but spec asked for %s"
|
||||
e.message %= (spec_deps[dep.name].spec, dep.name,
|
||||
@ -2389,7 +2390,7 @@ def do_parse(self):
|
||||
# errors now?
|
||||
specs.append(self.spec(None, True))
|
||||
|
||||
except spack.parse.ParseError, e:
|
||||
except spack.parse.ParseError as e:
|
||||
raise SpecParseError(e)
|
||||
|
||||
# If the spec has an os or a target and no platform, give it
|
||||
@ -2834,4 +2835,4 @@ class AmbiguousHashError(SpecError):
|
||||
def __init__(self, msg, *specs):
|
||||
super(AmbiguousHashError, self).__init__(msg)
|
||||
for spec in specs:
|
||||
print ' ', spec.format('$.$@$%@+$+$=$#')
|
||||
print(' ', spec.format('$.$@$%@+$+$=$#'))
|
||||
|
@ -24,15 +24,22 @@
|
||||
##############################################################################
|
||||
import StringIO
|
||||
import collections
|
||||
from contextlib import contextmanager
|
||||
import os
|
||||
import unittest
|
||||
import contextlib
|
||||
|
||||
import spack
|
||||
import spack.cmd
|
||||
|
||||
FILE_REGISTRY = collections.defaultdict(StringIO.StringIO)
|
||||
|
||||
|
||||
# Monkey-patch open to write module files to a StringIO instance
|
||||
@contextmanager
|
||||
@contextlib.contextmanager
|
||||
def mock_open(filename, mode):
|
||||
if not mode == 'wb':
|
||||
raise RuntimeError('test.test_install : unexpected opening mode for monkey-patched open')
|
||||
message = 'test.test_install : unexpected opening mode for mock_open'
|
||||
raise RuntimeError(message)
|
||||
|
||||
FILE_REGISTRY[filename] = StringIO.StringIO()
|
||||
|
||||
@ -43,18 +50,14 @@ def mock_open(filename, mode):
|
||||
FILE_REGISTRY[filename] = handle.getvalue()
|
||||
handle.close()
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
import spack
|
||||
import spack.cmd
|
||||
|
||||
|
||||
# The use of __import__ is necessary to maintain a name with hyphen (which cannot be an identifier in python)
|
||||
# The use of __import__ is necessary to maintain a name with hyphen (which
|
||||
# cannot be an identifier in python)
|
||||
test_install = __import__("spack.cmd.test-install", fromlist=['test_install'])
|
||||
|
||||
|
||||
class MockSpec(object):
|
||||
|
||||
def __init__(self, name, version, hashStr=None):
|
||||
self._dependencies = {}
|
||||
self.name = name
|
||||
@ -96,6 +99,7 @@ def short_spec(self):
|
||||
|
||||
|
||||
class MockPackage(object):
|
||||
|
||||
def __init__(self, spec, buildLogPath):
|
||||
self.name = spec.name
|
||||
self.spec = spec
|
||||
@ -107,6 +111,7 @@ def do_install(self, *args, **kwargs):
|
||||
|
||||
|
||||
class MockPackageDb(object):
|
||||
|
||||
def __init__(self, init=None):
|
||||
self.specToPkg = {}
|
||||
if init:
|
||||
@ -127,6 +132,7 @@ def mock_fetch_log(path):
|
||||
|
||||
|
||||
class MockArgs(object):
|
||||
|
||||
def __init__(self, package):
|
||||
self.package = package
|
||||
self.jobs = None
|
||||
@ -162,7 +168,7 @@ def monkey_parse_specs(x, concretize):
|
||||
test_install.open = mock_open
|
||||
|
||||
# Clean FILE_REGISTRY
|
||||
FILE_REGISTRY = collections.defaultdict(StringIO.StringIO)
|
||||
FILE_REGISTRY.clear()
|
||||
|
||||
pkgX.installed = False
|
||||
pkgY.installed = False
|
||||
@ -188,7 +194,7 @@ def tearDown(self):
|
||||
spack.repo = self.saved_db
|
||||
|
||||
def test_installing_both(self):
|
||||
test_install.test_install(None, MockArgs('X') )
|
||||
test_install.test_install(None, MockArgs('X'))
|
||||
self.assertEqual(len(FILE_REGISTRY), 1)
|
||||
for _, content in FILE_REGISTRY.items():
|
||||
self.assertTrue('tests="2"' in content)
|
||||
@ -204,4 +210,5 @@ def test_dependency_already_installed(self):
|
||||
self.assertTrue('tests="2"' in content)
|
||||
self.assertTrue('failures="0"' in content)
|
||||
self.assertTrue('errors="0"' in content)
|
||||
self.assertEqual(sum('skipped' in line for line in content.split('\n')), 2)
|
||||
self.assertEqual(
|
||||
sum('skipped' in line for line in content.split('\n')), 2)
|
||||
|
Loading…
Reference in New Issue
Block a user