Duplicated scenario name will induce error in py33

Bug #1244571 reported by Kui Shi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
testscenarios
Invalid
High
Kui Shi

Bug Description

Duplicated scenario will induce error in py33.

If there is duplicated scenario name, the generated test cases can not be sorted in py33.

Here is the sample:

https://bugs.launchpad.net/python-heatclient/+bug/1243096

We should check it while expanding the "scenarios".

Kui Shi (skuicloud)
summary: - check whether there is duplicated name in scenarios
+ Duplicated scenario name will induce error in py33
Changed in testscenarios:
assignee: nobody → Kui Shi (skuicloud)
Revision history for this message
Kui Shi (skuicloud) wrote :

Robert: I have made a patch for this issue, but I can not find the repository url. Would you show me some guidance please ?

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)

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

Robert: The change needs a corresponding test case in tests/test_scenarios.py. But I don't konw how to test it. Would you give me some help please ?

Revision history for this message
IAN DELANEY (johneed) wrote :

yes, Robert

Revision history for this message
Robert Collins (lifeless) wrote :

@Kui hi, sorry for the slow response. ETOOMUCHMAIL.

bzr branch lp:testscenarios will get you trunk code. Or you can attach a patch here.

Cheers,
Rob

Changed in testscenarios:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Robert Collins (lifeless) wrote :

That said, I suspect its up to the runner to really address this, not sure if we need to cater specifically here or not.

Revision history for this message
Robert Collins (lifeless) wrote :

So, to wrap this up:
 - because generation is potentially local, this is best handled and reported globally by the runner
 - testtools now does this.

Closing this

Changed in testscenarios:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.