~ubuntu-branches/ubuntu/oneiric/enigmail/oneiric-updates

« back to all changes in this revision

Viewing changes to config/mozunit.py

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2010-04-10 01:42:24 UTC
  • Revision ID: james.westby@ubuntu.com-20100410014224-fbq9ui5x3b0h2t36
Tags: 2:1.0.1-0ubuntu1
* First releaase of enigmail 1.0.1 for tbird/icedove 3
  (LP: #527138)
* redo packaging from scratch 
  + add debian/make-orig target that uses xulrunner provided
    buildsystem + enigmail tarball to produce a proper orig.tar.gz
  + use debhelper 7 with mozilla-devscripts
  + use debian source format 3.0 (quilt)
  + patch enigmail to use frozen API only
    - add debian/patches/frozen_api.diff
  + patch build system to not link against -lxul - which isnt
    available for sdks produced by all-static apps like tbird
    - add debian/patches/build_system_dont_link_libxul.diff
  + add minimal build-depends to control

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from unittest import TextTestRunner as _TestRunner, TestResult as _TestResult
 
2
import inspect
 
3
 
 
4
'''Helper to make python unit tests report the way that the Mozilla
 
5
unit test infrastructure expects tests to report.
 
6
 
 
7
Usage:
 
8
 
 
9
import unittest
 
10
from mozunit import MozTestRunner
 
11
 
 
12
if __name__ == '__main__':
 
13
    unittest.main(testRunner=MozTestRunner())
 
14
'''
 
15
 
 
16
class _MozTestResult(_TestResult):
 
17
    def __init__(self, stream, descriptions):
 
18
        _TestResult.__init__(self)
 
19
        self.stream = stream
 
20
        self.descriptions = descriptions
 
21
 
 
22
    def getDescription(self, test):
 
23
        if self.descriptions:
 
24
            return test.shortDescription() or str(test)
 
25
        else:
 
26
            return str(test)
 
27
 
 
28
    def addSuccess(self, test):
 
29
        _TestResult.addSuccess(self, test)
 
30
        filename = inspect.getfile(test.__class__)
 
31
        testname = test._testMethodName
 
32
        self.stream.writeln("TEST-PASS | %s | %s" % (filename, testname))
 
33
 
 
34
    def addError(self, test, err):
 
35
        _TestResult.addError(self, test, err)
 
36
        self.printFail(test, err)
 
37
 
 
38
    def addFailure(self, test, err):
 
39
        _TestResult.addFailure(self, test, err)
 
40
        self.printFail(test,err)
 
41
 
 
42
    def printFail(self, test, err):
 
43
        exctype, value, tb = err
 
44
        # Skip test runner traceback levels
 
45
        while tb and self._is_relevant_tb_level(tb):
 
46
            tb = tb.tb_next
 
47
        if not tb:
 
48
            self.stream.writeln("TEST-UNEXPECTED-FAIL | NO TRACEBACK |")
 
49
        _f, _ln, _t = inspect.getframeinfo(tb)[:3]
 
50
        self.stream.writeln("TEST-UNEXPECTED-FAIL | %s | line %d, %s: %s" % 
 
51
                            (_f, _ln, _t, value.message))
 
52
 
 
53
    def printErrorList(self):
 
54
        for test, err in self.errors:
 
55
            self.stream.writeln("ERROR: %s" % self.getDescription(test))
 
56
            self.stream.writeln("%s" % err)
 
57
 
 
58
 
 
59
class MozTestRunner(_TestRunner):
 
60
    def _makeResult(self):
 
61
        return _MozTestResult(self.stream, self.descriptions)
 
62
    def run(self, test):
 
63
        result = self._makeResult()
 
64
        test(result)
 
65
        result.printErrorList()
 
66
        return result