Skip to content

Commit

Permalink
need to number format fields in Python 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris NeJame committed Jun 22, 2017
1 parent 3396af2 commit f9a2fc5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
62 changes: 31 additions & 31 deletions contextional/contextional.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ def _clear_stack(self):
for group in teardown_groups:
if group._teardowns:
LOGGER.debug(
"Running tearDowns for group:\n{}".format(
"Running tearDowns for group:\n{0}".format(
group._get_full_ancestry_description(True),
),
)
for i, teardown in enumerate(group._teardowns):
LOGGER.debug("Running tearDown #{}".format(i))
LOGGER.debug("Running tearDown #{0}".format(i))
teardown()
self._level_stack.remove(group)
LOGGER.debug("Teardowns complete.")
Expand Down Expand Up @@ -324,11 +324,11 @@ def test(case):
new_group._parent = last_group
new_group._args = args
if isinstance(params, Mapping):
new_group._description += " {}".format(gid)
new_group._description += " {0}".format(gid)
elif no_params:
pass
else:
new_group._description += " {}".format(params[gid])
new_group._description += " {0}".format(params[gid])
last_group._children.append(new_group)
original_new_child = self._group
self._group = last_group
Expand Down Expand Up @@ -935,7 +935,7 @@ def _set_class_name_for_group(cls, group, fixture_label):
fixtures, as it points to the specific point in the ancestry that had
the problem.
"""
cls._err_description = "Contextional Case {}:\n{}".format(
cls._err_description = "Contextional Case {0}:\n{1}".format(
fixture_label,
group._get_full_ancestry_description(indented=True),
)
Expand Down Expand Up @@ -1014,7 +1014,7 @@ def _set_test_descriptions(cls, setup_ancestry):
indentation,
level_description,
)
cls._description += "{}{}".format(
cls._description += "{0}{1}".format(
(indent * (cls._group._level + 1)),
cls._case._description,
)
Expand All @@ -1023,12 +1023,12 @@ def _set_test_descriptions(cls, setup_ancestry):
for group in setup_ancestry:
indentation = (indent * group._level)
level_description = group._description
cls._full_description += "\n{}{}".format(
cls._full_description += "\n{0}{1}".format(
indentation,
level_description,
)

cls._full_description = "\n{}\n{}{}".format(
cls._full_description = "\n{0}\n{1}{2}".format(
cls._group._get_full_ancestry_description(indented=True),
(indent * (cls._group._level + 2)),
cls._case._description,
Expand Down Expand Up @@ -1138,25 +1138,25 @@ def setUp(self):
self._case._test_started = True
if self._auto_fail is True:
LOGGER.debug(
"CASCADING FAILURE - Not setting up for test:\n{}".format(
"CASCADING FAILURE - Not setting up for test:\n{0}".format(
self._group._get_full_ancestry_description(indented=True),
(" " * (self._group._level + 1)),
self._case._description,
),
)
return
LOGGER.debug(
"Running test setUps for test:\n{}\n{}{}".format(
"Running test setUps for test:\n{0}\n{1}{2}".format(
self._group._get_full_ancestry_description(indented=True),
(" " * (self._group._level + 1)),
self._case._description,
),
)
try:
for i, setup in enumerate(self._group._test_setups):
LOGGER.debug("Running test setUp #{}".format(i))
LOGGER.debug("Running test setUp #{0}".format(i))
setup()
LOGGER.debug("test setUp #{} complete.".format(i))
LOGGER.debug("test setUp #{0} complete.".format(i))
except Exception:
LOGGER.debug(
"Couldn't complete setups for the test due to exception.",
Expand All @@ -1173,25 +1173,25 @@ def tearDown(self):
"""The cleanup required to be run after each test in the group."""
if self._auto_fail is True:
LOGGER.debug(
"CASCADING FAILURE - Not tearing down test:\n{}".format(
"CASCADING FAILURE - Not tearing down test:\n{0}".format(
self._group._get_full_ancestry_description(indented=True),
(" " * (self._group._level + 1)),
self._case._description,
),
)
return
LOGGER.debug(
"Running test tearDowns for test:\n{}\n{}{}".format(
"Running test tearDowns for test:\n{0}\n{1}{2}".format(
self._group._get_full_ancestry_description(indented=True),
(" " * (self._group._level + 1)),
self._case._description,
),
)
try:
for i, teardown in enumerate(self._group._test_teardowns):
LOGGER.debug("Running test tearDown #{}".format(i))
LOGGER.debug("Running test tearDown #{0}".format(i))
teardown()
LOGGER.debug("test tearDown #{} complete.".format(i))
LOGGER.debug("test tearDown #{0} complete.".format(i))
except Exception:
LOGGER.debug(
"Couldn't complete teardowns for the test due to exception.",
Expand Down Expand Up @@ -1245,7 +1245,7 @@ def run(self, result=None):

if self._auto_fail:
LOGGER.debug(
"CASCADING FAILURE - Not setting up group:\n{}".format(
"CASCADING FAILURE - Not setting up group:\n{0}".format(
str(self._group),
),
)
Expand All @@ -1256,7 +1256,7 @@ def run(self, result=None):

return super(GroupTestCase, self).run(self.temp_result)

LOGGER.debug("Setting up group:\n{}".format(str(self._group)))
LOGGER.debug("Setting up group:\n{0}".format(str(self._group)))
self._teardown_to_common_level()

for group in self._group._setup_ancestry:
Expand All @@ -1270,12 +1270,12 @@ def runTest(self):
__tracebackhide__ = True
if self._auto_fail is True:
LOGGER.debug(
"CASCADING FAILURE - Not running test:\n{}".format(
"CASCADING FAILURE - Not running test:\n{0}".format(
self._case._full_description,
),
)
raise CascadingFailureError()
LOGGER.debug("Running test:\n{}".format(self._case._full_description))
LOGGER.debug("Running test:\n{0}".format(self._case._full_description))
# Execute the actual test case function.
try:
self._case(self)
Expand All @@ -1288,7 +1288,7 @@ def runTest(self):
LOGGER.debug("Test completed successfully.")


TEST_CLASS_NAME_TEMPLATE = "ContextionalCase_{}"
TEST_CLASS_NAME_TEMPLATE = "ContextionalCase_{0}"


class Group(object):
Expand Down Expand Up @@ -1499,24 +1499,24 @@ def _setup_group(self, result=None):
)
if self._cascading_failure_in_progress:
LOGGER.debug(
"CASCADING FAILURE - Not setting up group:\n{}".format(
"CASCADING FAILURE - Not setting up group:\n{0}".format(
str(self),
),
)
return
LOGGER.debug("Running setUps for group:\n{}".format(str(self)))
LOGGER.debug("Running setUps for group:\n{0}".format(str(self)))
if result is not None:
if hasattr(result, "stream"):
if result.showAll:
result.stream.write(self._inline_description + " ")
try:
for i, setup in enumerate(self._setups):
LOGGER.debug("Running setUp #{}".format(i))
LOGGER.debug("Running setUp #{0}".format(i))
if isinstance(self._args, Mapping):
setup(**self._args)
else:
setup(*self._args)
LOGGER.debug("setUp #{} complete.".format(i))
LOGGER.debug("setUp #{0} complete.".format(i))
except:
LOGGER.debug("Group setup failed.", exc_info=True)
if self._cascading_failure:
Expand Down Expand Up @@ -1549,19 +1549,19 @@ def _teardown_group(self, result=None):
if self._cascading_failure_in_progress:
if not self._cascading_failure_root:
LOGGER.debug(
"CASCADING FAILURE - Not tearing down group:\n{}".format(
"CASCADING FAILURE - Not tearing down group:\n{0}".format(
str(self),
),
)
self._helper._level_stack.remove(self)
return
if self._teardowns:
LOGGER.debug("Running tearDowns for group:\n{}".format(str(self)))
LOGGER.debug("Running tearDowns for group:\n{0}".format(str(self)))
try:
for i, teardown in enumerate(self._teardowns):
LOGGER.debug("Running tearDown #{}".format(i))
LOGGER.debug("Running tearDown #{0}".format(i))
teardown()
LOGGER.debug("tearDown #{} complete.".format(i))
LOGGER.debug("tearDown #{0} complete.".format(i))
except:
LOGGER.debug("Group teardown failed.", exc_info=True)
if result is not None:
Expand Down Expand Up @@ -1626,7 +1626,7 @@ def _inline_description(self):

@property
def _full_description(self):
desc = "\n{}\n{}{}".format(
desc = "\n{0}\n{1}{2}".format(
str(self._group),
(" " * (self._group._level + 2)),
self._description,
Expand Down Expand Up @@ -1660,7 +1660,7 @@ def __init__(self, case):
self._case = case

def __str__(self):
desc = "\n{}\n{}{}".format(
desc = "\n{0}\n{1}{2}".format(
str(self._case._group),
(" " * (self._case._group._level + 2)),
self._case._description,
Expand Down
4 changes: 2 additions & 2 deletions contextional/pytest_contextional.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def handle_teardowns(item):
for group in ignored_teardown_groups:
if not group._cascading_failure_root:
LOGGER.debug(
"CASCADING FAILURE - Not tearing down group:\n{}"
"CASCADING FAILURE - Not tearing down group:\n{0}"
.format(
group._get_full_ancestry_description(True),
),
Expand All @@ -86,7 +86,7 @@ def handle_teardowns(item):
else:
end_desc = td_lvl._get_full_ancestry_description(True)
LOGGER.debug(
"Tearing down group:\n{}\nto:\n{}".format(
"Tearing down group:\n{0}\nto:\n{1}".format(
case._group._get_full_ancestry_description(True),
end_desc,
),
Expand Down

0 comments on commit f9a2fc5

Please sign in to comment.