summaryrefslogtreecommitdiffstats
path: root/tests/errors/test_exceptions.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/errors/test_exceptions.py')
-rw-r--r--tests/errors/test_exceptions.py39
1 files changed, 21 insertions, 18 deletions
diff --git a/tests/errors/test_exceptions.py b/tests/errors/test_exceptions.py
index 2fba25a6..079a5406 100644
--- a/tests/errors/test_exceptions.py
+++ b/tests/errors/test_exceptions.py
@@ -16,19 +16,19 @@ def dispatch(exc, *args):
def gen_xml(exc, *args):
- data = {'module': 'data'} # noqa
+ data = {"module": "data"} # noqa
raise exc(*args)
class TestInvalidAttributeError(base.BaseTestCase):
-
def test_no_valid_values(self):
# When given no valid values, InvalidAttributeError simply displays a
# message indicating the invalid value, the component type, the
# component name, and the attribute name.
message = "'{0}' is an invalid value for attribute {1}.{2}".format(
- "fnord", "type.name", "fubar")
+ "fnord", "type.name", "fubar"
+ )
with ExpectedException(errors.InvalidAttributeError, message):
dispatch(errors.InvalidAttributeError, "fubar", "fnord")
@@ -37,46 +37,49 @@ class TestInvalidAttributeError(base.BaseTestCase):
# indicating the invalid value, the component type, the component name,
# and the attribute name; additionally, it lists the valid values for
# the current component type & name.
- valid_values = ['herp', 'derp']
+ valid_values = ["herp", "derp"]
message = "'{0}' is an invalid value for attribute {1}.{2}".format(
- "fnord", "type.name", "fubar")
+ "fnord", "type.name", "fubar"
+ )
message += "\nValid values include: {0}".format(
- ', '.join("'{0}'".format(value) for value in valid_values))
+ ", ".join("'{0}'".format(value) for value in valid_values)
+ )
with ExpectedException(errors.InvalidAttributeError, message):
- dispatch(errors.InvalidAttributeError, "fubar", "fnord",
- valid_values)
+ dispatch(errors.InvalidAttributeError, "fubar", "fnord", valid_values)
class TestMissingAttributeError(base.BaseTestCase):
-
def test_with_single_missing_attribute(self):
# When passed a single missing attribute, display a message indicating
# * the missing attribute
# * which component type and component name is missing it.
- missing_attribute = 'herp'
+ missing_attribute = "herp"
message = "Missing {0} from an instance of '{1}'".format(
- missing_attribute, 'type.name')
+ missing_attribute, "type.name"
+ )
with ExpectedException(errors.MissingAttributeError, message):
dispatch(errors.MissingAttributeError, missing_attribute)
- with ExpectedException(errors.MissingAttributeError,
- message.replace('type.name', 'module')):
+ with ExpectedException(
+ errors.MissingAttributeError, message.replace("type.name", "module")
+ ):
gen_xml(errors.MissingAttributeError, missing_attribute)
def test_with_multiple_missing_attributes(self):
# When passed multiple missing attributes, display a message indicating
# * the missing attributes
# * which component type and component name is missing it.
- missing_attribute = ['herp', 'derp']
+ missing_attribute = ["herp", "derp"]
message = "One of {0} must be present in '{1}'".format(
- ', '.join("'{0}'".format(value) for value in missing_attribute),
- 'type.name')
+ ", ".join("'{0}'".format(value) for value in missing_attribute), "type.name"
+ )
with ExpectedException(errors.MissingAttributeError, message):
dispatch(errors.MissingAttributeError, missing_attribute)
- with ExpectedException(errors.MissingAttributeError,
- message.replace('type.name', 'module')):
+ with ExpectedException(
+ errors.MissingAttributeError, message.replace("type.name", "module")
+ ):
gen_xml(errors.MissingAttributeError, missing_attribute)