~apport-hackers/apport/trunk

« back to all changes in this revision

Viewing changes to test/test_hookutils.py

  • Committer: Martin Pitt
  • Date: 2012-04-11 16:09:08 UTC
  • Revision ID: martin.pitt@canonical.com-20120411160908-cypjfe8pkzqp5lbd
* Fix the whole code to be PEP-8 compatible, and enforce this in test/run by running the "pep8" tool.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
import apport.hookutils
5
5
 
 
6
 
6
7
class T(unittest.TestCase):
7
8
    def setUp(self):
8
9
        self.workdir = tempfile.mkdtemp()
20
21
            asm.flush()
21
22
            ko = tempfile.NamedTemporaryFile(prefix='%s-' % (license),
22
23
                                             suffix='.ko')
23
 
            subprocess.call(['/usr/bin/as',asm.name,'-o',ko.name])
 
24
            subprocess.call(['/usr/bin/as', asm.name, '-o', ko.name])
24
25
            return ko
25
26
 
26
27
        good_ko = _build_ko('GPL')
27
 
        bad_ko  = _build_ko('BAD')
 
28
        bad_ko = _build_ko('BAD')
28
29
 
29
30
        # test:
30
31
        #  - loaded real module
41
42
        # check via nonfree_kernel_modules logic
42
43
        f = tempfile.NamedTemporaryFile()
43
44
        f.write(('isofs\ndoes-not-exist\n%s\n%s\n' %
44
 
                (good_ko.name,bad_ko.name)).encode())
 
45
                (good_ko.name, bad_ko.name)).encode())
45
46
        f.flush()
46
47
        nonfree = apport.hookutils.nonfree_kernel_modules(f.name)
47
48
        self.assertFalse('isofs' in nonfree)
68
69
        self.assertEqual(report['BootDmesg'][:50], 'existingboot')
69
70
        self.assertTrue(report['CurrentDmesg'].startswith(b'['))
70
71
 
71
 
        report = {'BootDmesg': 'existingboot', 'CurrentDmesg': 'existingcurrent' }
 
72
        report = {'BootDmesg': 'existingboot', 'CurrentDmesg': 'existingcurrent'}
72
73
 
73
74
        apport.hookutils.attach_dmesg(report)
74
75
        self.assertEqual(report['BootDmesg'], 'existingboot')