Fix hacking errors
As another step in aligning further with OpenStack practices, stop ignoring the hacking style checks. Change-Id: I16c9f0ca3be5790176467377303817249e7643ea
This commit is contained in:
parent
c179d9b04d
commit
6b74b65449
@ -25,7 +25,8 @@ def get_elements_dir():
|
|||||||
|
|
||||||
|
|
||||||
def dependencies(element, elements_dir=None):
|
def dependencies(element, elements_dir=None):
|
||||||
""" Return the non-transitive list of dependencies for a single element
|
"""Return the non-transitive list of dependencies for a single element.
|
||||||
|
|
||||||
:param user_elements: iterable enumerating elements a user has requested
|
:param user_elements: iterable enumerating elements a user has requested
|
||||||
:param elements_dir: the elements dir to read from. If not supplied,
|
:param elements_dir: the elements dir to read from. If not supplied,
|
||||||
inferred by calling get_elements_dir().
|
inferred by calling get_elements_dir().
|
||||||
@ -55,7 +56,7 @@ def dependencies(element, elements_dir=None):
|
|||||||
|
|
||||||
|
|
||||||
def expand_dependencies(user_elements, elements_dir=None):
|
def expand_dependencies(user_elements, elements_dir=None):
|
||||||
""" Expand user requested elements using element-deps files.
|
"""Expand user requested elements using element-deps files.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
:param user_elements: iterable enumerating the elements a user requested
|
:param user_elements: iterable enumerating the elements a user requested
|
||||||
|
@ -15,11 +15,10 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from testtools import TestCase
|
import fixtures
|
||||||
from fixtures import EnvironmentVariable, TempDir
|
import testtools
|
||||||
|
|
||||||
from diskimage_builder.elements import expand_dependencies
|
from diskimage_builder import elements
|
||||||
from diskimage_builder.elements import get_elements_dir
|
|
||||||
|
|
||||||
data_dir = os.path.abspath(
|
data_dir = os.path.abspath(
|
||||||
os.path.join(os.path.dirname(__file__), 'test-elements'))
|
os.path.join(os.path.dirname(__file__), 'test-elements'))
|
||||||
@ -33,11 +32,11 @@ def _populate_element(element_dir, element_name, element_deps=[]):
|
|||||||
deps_file.write("\n".join(element_deps))
|
deps_file.write("\n".join(element_deps))
|
||||||
|
|
||||||
|
|
||||||
class TestElementDeps(TestCase):
|
class TestElementDeps(testtools.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestElementDeps, self).setUp()
|
super(TestElementDeps, self).setUp()
|
||||||
self.element_dir = self.useFixture(TempDir()).path
|
self.element_dir = self.useFixture(fixtures.TempDir()).path
|
||||||
_populate_element(self.element_dir, 'requires-foo', ['foo'])
|
_populate_element(self.element_dir, 'requires-foo', ['foo'])
|
||||||
_populate_element(self.element_dir, 'foo')
|
_populate_element(self.element_dir, 'foo')
|
||||||
_populate_element(self.element_dir,
|
_populate_element(self.element_dir,
|
||||||
@ -48,42 +47,44 @@ class TestElementDeps(TestCase):
|
|||||||
_populate_element(self.element_dir, 'circular2', ['circular1'])
|
_populate_element(self.element_dir, 'circular2', ['circular1'])
|
||||||
|
|
||||||
def test_non_transitive_deps(self):
|
def test_non_transitive_deps(self):
|
||||||
result = expand_dependencies(['requires-foo'],
|
result = elements.expand_dependencies(
|
||||||
elements_dir=self.element_dir)
|
['requires-foo'],
|
||||||
|
elements_dir=self.element_dir)
|
||||||
self.assertEquals(set(['requires-foo', 'foo']), result)
|
self.assertEquals(set(['requires-foo', 'foo']), result)
|
||||||
|
|
||||||
def test_missing_deps(self):
|
def test_missing_deps(self):
|
||||||
self.assertRaises(SystemExit, expand_dependencies, ['fake'],
|
self.assertRaises(SystemExit, elements.expand_dependencies, ['fake'],
|
||||||
self.element_dir)
|
self.element_dir)
|
||||||
|
|
||||||
def test_transitive_deps(self):
|
def test_transitive_deps(self):
|
||||||
result = expand_dependencies(['requires-requires-foo'],
|
result = elements.expand_dependencies(
|
||||||
elements_dir=self.element_dir)
|
['requires-requires-foo'], elements_dir=self.element_dir)
|
||||||
self.assertEquals(set(['requires-requires-foo',
|
self.assertEquals(set(['requires-requires-foo',
|
||||||
'requires-foo',
|
'requires-foo',
|
||||||
'foo']), result)
|
'foo']), result)
|
||||||
|
|
||||||
def test_no_deps(self):
|
def test_no_deps(self):
|
||||||
result = expand_dependencies(['foo'],
|
result = elements.expand_dependencies(
|
||||||
elements_dir=self.element_dir)
|
['foo'], elements_dir=self.element_dir)
|
||||||
self.assertEquals(set(['foo']), result)
|
self.assertEquals(set(['foo']), result)
|
||||||
|
|
||||||
def test_self(self):
|
def test_self(self):
|
||||||
result = expand_dependencies(['self'],
|
result = elements.expand_dependencies(
|
||||||
elements_dir=self.element_dir)
|
['self'], elements_dir=self.element_dir)
|
||||||
self.assertEquals(set(['self']), result)
|
self.assertEquals(set(['self']), result)
|
||||||
|
|
||||||
def test_circular(self):
|
def test_circular(self):
|
||||||
result = expand_dependencies(['circular1'],
|
result = elements.expand_dependencies(
|
||||||
elements_dir=self.element_dir)
|
['circular1'], elements_dir=self.element_dir)
|
||||||
self.assertEquals(set(['circular1', 'circular2']), result)
|
self.assertEquals(set(['circular1', 'circular2']), result)
|
||||||
|
|
||||||
|
|
||||||
class TestElements(TestCase):
|
class TestElements(testtools.TestCase):
|
||||||
def test_depends_on_env(self):
|
def test_depends_on_env(self):
|
||||||
self.useFixture(EnvironmentVariable('ELEMENTS_PATH', '/foo/bar'))
|
self.useFixture(
|
||||||
self.assertEquals('/foo/bar', get_elements_dir())
|
fixtures.EnvironmentVariable('ELEMENTS_PATH', '/foo/bar'))
|
||||||
|
self.assertEquals('/foo/bar', elements.get_elements_dir())
|
||||||
|
|
||||||
def test_env_not_set(self):
|
def test_env_not_set(self):
|
||||||
self.useFixture(EnvironmentVariable('ELEMENTS_PATH', ''))
|
self.useFixture(fixtures.EnvironmentVariable('ELEMENTS_PATH', ''))
|
||||||
self.assertRaises(Exception, get_elements_dir, ())
|
self.assertRaises(Exception, elements.get_elements_dir, ())
|
||||||
|
2
tox.ini
2
tox.ini
@ -26,6 +26,6 @@ commands = bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
|
|||||||
downloadcache = ~/cache/pip
|
downloadcache = ~/cache/pip
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore = E125,H
|
ignore = E125
|
||||||
builtins = _
|
builtins = _
|
||||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
exclude = .venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build
|
||||||
|
Loading…
Reference in New Issue
Block a user