~ricgard/maas/vs-repeat-ui-improvement--2.2

« back to all changes in this revision

Viewing changes to src/maas/testing/__init__.py

  • Committer: Gavin Panella
  • Date: 2012-01-19 10:37:57 UTC
  • mfrom: (16.3.22 test-bling)
  • Revision ID: gavin.panella@canonical.com-20120119103757-surtgos6dn4krulo
[r=rvba] Adds testtools and testresources, templates for new source files, import formatting utility from Launchpad, and fixes some lint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
__all__ = []
 
2
__metaclass__ = type
 
3
 
 
4
import django.test
 
5
import testresources
 
6
import testtools
 
7
 
 
8
 
 
9
class TestCase(testtools.TestCase, django.test.TestCase):
 
10
    """`TestCase` for Metal as a Service.
 
11
 
 
12
    Supports test resources and fixtures.
 
13
    """
 
14
 
 
15
    # testresources.ResourcedTestCase does something similar to this class
 
16
    # (with respect to setUpResources and tearDownResources) but it explicitly
 
17
    # up-calls to unittest.TestCase instead of using super() even though it is
 
18
    # not guaranteed that the next class in the inheritance chain is
 
19
    # unittest.TestCase.
 
20
 
 
21
    resources = ()
 
22
 
 
23
    def setUp(self):
 
24
        super(TestCase, self).setUp()
 
25
        self.setUpResources()
 
26
 
 
27
    def setUpResources(self):
 
28
        testresources.setUpResources(
 
29
            self, self.resources, testresources._get_result())
 
30
 
 
31
    def tearDown(self):
 
32
        self.tearDownResources()
 
33
        super(TestCase, self).tearDown()
 
34
 
 
35
    def tearDownResources(self):
 
36
        testresources.tearDownResources(
 
37
            self, self.resources, testresources._get_result())