1
# Copyright 2012 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Tests for `maastesting.scenarios`."""
6
from __future__ import (
17
from maastesting.scenarios import WithScenarios
18
from maastesting.testcase import TestCase
21
class TestWithScenarios(TestCase):
23
def test_scenarios_applied(self):
24
# Scenarios are applied correctly when a test is called via __call__()
29
class Test(WithScenarios, unittest.TestCase):
32
("one", dict(token="one")),
33
("two", dict(token="two")),
37
events.append(self.token)
42
self.assertEqual(["one", "two"], events)
44
def test_scenarios_applied_by_call(self):
45
# Scenarios are applied by __call__() when it is called first, and not
50
class Test(WithScenarios, unittest.TestCase):
53
("one", dict(token="one")),
54
("two", dict(token="two")),
58
events.append(self.token)
60
def run(self, result=None):
61
# Call-up right past WithScenarios.run() to show that it is
62
# not responsible for applying scenarios, and __call__() is.
63
super(WithScenarios, self).run(result)
68
self.assertEqual(["one", "two"], events)