~ubuntu-branches/ubuntu/saucy/migrate/saucy-proposed

« back to all changes in this revision

Viewing changes to test/fixture/base.py

  • Committer: Bazaar Package Importer
  • Author(s): Jan Dittberner
  • Date: 2010-07-12 00:24:57 UTC
  • mfrom: (1.1.5 upstream) (2.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100712002457-4j2fdmco4u9kqzm5
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# -*- coding: utf-8 -*-
3
 
 
4
 
import re
5
 
import unittest
6
 
 
7
 
from nose.tools import raises, eq_
8
 
 
9
 
 
10
 
class Base(unittest.TestCase):
11
 
 
12
 
    def setup_method(self,func=None):
13
 
        self.setUp()
14
 
 
15
 
    def teardown_method(self,func=None):
16
 
        self.tearDown()
17
 
    
18
 
    def assertEqualsIgnoreWhitespace(self, v1, v2):
19
 
        """Compares two strings that should be\
20
 
        identical except for whitespace
21
 
        """
22
 
        def strip_whitespace(s):
23
 
            return re.sub(r'\s', '', s)
24
 
 
25
 
        line1 = strip_whitespace(v1)
26
 
        line2 = strip_whitespace(v2)
27
 
 
28
 
        self.assertEquals(line1, line2, "%s != %s" % (v1, v2))
29
 
 
30
 
    def ignoreErrors(self, func, *p,**k):
31
 
        """Call a function, ignoring any exceptions"""
32
 
        try:
33
 
            func(*p,**k)
34
 
        except:
35
 
            pass