~ubuntu-branches/ubuntu/jaunty/landscape-client/jaunty-proposed

« back to all changes in this revision

Viewing changes to landscape/lib/tests/test_warning.py

  • Committer: Bazaar Package Importer
  • Author(s): Christopher Armstrong
  • Date: 2009-04-09 17:09:50 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090409170950-mc5mqadawk0ls2vc
Tags: 1.0.29-0ubuntu0.9.04.0
* New upstream bugfix release (LP: #358744)
  - Add a timeout to HTTP operations to avoid hanging (LP: #349737)
  - Clean up environment variables on startup to avoid propagating
    variables that will corrupt package installation (LP: #348681)
  - Clean up FDs on startup for the same reason (LP: #352458)
  - Catch and handle certain errors from smart (such as invalid package
    data) to avoid "stuck" Landscape activities (LP: #268745)
  - Don't print warnings meant for developers to the console (LP: #336669)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import warnings
 
2
 
 
3
from twisted.trial.unittest import TestCase
 
4
 
 
5
from landscape.lib.warning import hide_warnings
 
6
 
 
7
 
 
8
class WarningTest(TestCase):
 
9
    def setUp(self):
 
10
        super(WarningTest, self).setUp()
 
11
        self.orig_filters = warnings.filters[:]
 
12
 
 
13
    def tearDown(self):
 
14
        super(WarningTest, self).tearDown()
 
15
        warnings.filters[:] = self.orig_filters
 
16
 
 
17
    def test_hide_warnings(self):
 
18
        hide_warnings()
 
19
        filters = warnings.filters[:2]
 
20
 
 
21
        # Warning filters are processed beginning to end, and the first filter
 
22
        # which matches a particular warning is used.
 
23
        
 
24
        self.assertEquals(
 
25
            filters,
 
26
            # The frontmost should "default" (i.e.  print) on UserWarnings
 
27
            [("default", None, UserWarning, None, 0),
 
28
             # The one just behind that should indicate that we should ignore
 
29
             # all other warnings.
 
30
             ("ignore", None, Warning, None, 0)])