Comment 2 for bug 1244571

Revision history for this message
Kui Shi (skuicloud) wrote :

Here is the patch:
---------------------------------

--- scenarios.py.old 2013-10-25 06:21:18.920665452 +0800
+++ scenarios.py 2013-10-25 05:47:21.984585100 +0800
@@ -36,12 +36,13 @@

 def apply_scenario(scenario, test):
     """Apply scenario to test.
-
+
     :param scenario: A tuple (name, parameters) to apply to the test. The test
         is cloned, its id adjusted to have (name) after it, and the parameters
         dict is used to update the new test.
     :param test: The test to apply the scenario to. This test is unaltered.
     :return: A new test cloned from test, with the scenario applied.
+
     """
     name, parameters = scenario
     scenario_suffix = '(' + name + ')'
@@ -59,10 +60,22 @@
 def apply_scenarios(scenarios, test):
     """Apply many scenarios to a test.

+ Duplicate name in scenarios is not permitted.
     :param scenarios: An iterable of scenarios.
     :param test: A test to apply the scenarios to.
     :return: A generator of tests.
     """
+ seen = set()
+ duplicated = []
+ for (name, para) in scenarios:
+ if name not in seen:
+ seen.add(name)
+ else:
+ duplicated.append((name,para))
+
+ if duplicated:
+ raise Exception("Duplicated name defined in scenarios:", duplicated)
+
     for scenario in scenarios:
         yield apply_scenario(scenario, test)