Apply scenarios with a decorator
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
testscenarios |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
This is a wishlist - I'm posting this here to get feedback on my proposal before I start hacking.
Rationale:
========
I'd like to be able to apply scenarios to a single test without having to create a new test case class every time. Currently if I have something like this:
----
class WidgetTests(
scenarios = [('name', {})]
def test_one(self):
pass
----
...and I want to add another tests that need a different list of scenarios, my only recouse is to create a new class ('EvenMoreWidge
Proposal:
I would like to add a decorator that can be applied to a test function that would apply one or more scenarios to that test. Some examples follow:
-----
class WidgetTests(
@add_
def test_one(self):
pass
----
This would add a single scenario to 'test_one'.
----
class WidgetTests(
scenarios = [('foo', {}), ('bar', {})]
@add_scenarios = [('one', {}), ('two', {})])
def test_one(self):
pass
----
This would leave 'test_one' with four scenarios, essentially doing the same thing that 'multiple_
Is this feature possible, and if written, would it be considered for inclusion into testscenarios? Is there any guidance you can give me on writing this?
Cheers,
Changed in testscenarios: | |
assignee: | nobody → Thomi Richards (thomir) |
That sounds like a fine thing to have.