~ubuntu-branches/ubuntu/utopic/apport/utopic

« back to all changes in this revision

Viewing changes to test/test_report.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-08-22 11:58:45 UTC
  • mfrom: (148.1.68)
  • Revision ID: package-import@ubuntu.com-20120822115845-joeci881uk7fkt5r
Tags: 2.5.1-0ubuntu1
* New upstream release:
  - test_recoverable_problem.py: Fix test for calling test runner with
    absolute path.
  - packaging-apt-dpkg.py: Fix crash on writing virtual_mapping.db when
    running with --sandbox-dir and -S system or giving no --cache.
  - REThread.py: Fix re-raising of exceptions in Python 3. Thanks Martin
    Packman! (LP: #1024836)
  - apport-retrace: Keep compressed CoreDump from .crash files instead of
    uncompressing them into memory. This dramatically reduces memory usage.
    (LP: #981155)
  - Add an apport.memdbg() function which prints out current memory usage if
    APPORT_MEMDEBUG is set. Annotate apport-retrace with it.
  - hookutils.py: Allow specifying a list of profile names when using
    attach_mac_events(). Thanks Marc Deslauriers.
  - hookutils.py, attach_root_command_outputs() and root_command_output():
    Drop usage of sudo, kdesudo, and gksu, and replace with pkexec. For
    attach_root_command_outputs(), use a wrapper and proper .policy file
    which explains the action and works under every environment; thus
    attach_root_command_outputs() is preferred over root_command_output()
    now, as it provides a better user experience.
  - Package hooks which want to send the report to a different crash
    database than "default" can now also give the database specification
    itself in the "CrashDB" field, not just the DB name. With this, packages
    do not need to ship a separate /etc/apport/crashdb.conf.d/ file. Please
    see doc/package-hooks.txt for details. (LP: #551330)
  - report.py, add_hooks_info(): If reporting against a package/program in
    /opt, also search for package hooks in the corresponding /opt directory.
    This allows such hooks to define a custom crash database and thus report
    bugs against their own project instead of against the distribution.
    (LP: #1020503)
* debian/rules: Call dh_install with --list-missing, and ignore .pyc and
  .egg-info files.
* debian/apport.install: Install new polkit .policy and root_info_wrapper
  files, and add policykit-1 Recommends.
* debian/apport.install: Ship is-enabled script.
* debian/apport-kde.install: Ship userpass.ui file.
* Drop debian/apport-retrace.manpages and debian/apport.manpages and install
  the man pages from *.install instead. This works better with
  --list-missing.
* debian/apport.install: Install 000record-status pm-utils script, to
  unbreak suspend failure detection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
956
956
            apport.report._hook_dir = orig_hook_dir
957
957
            apport.report._common_hook_dir = orig_common_hook_dir
958
958
 
 
959
    def test_add_hooks_info_opt(self):
 
960
        '''add_hooks_info() for a package in /opt'''
 
961
 
 
962
        orig_hook_dir = apport.report._hook_dir
 
963
        apport.report._hook_dir = tempfile.mkdtemp()
 
964
        orig_common_hook_dir = apport.report._common_hook_dir
 
965
        apport.report._common_hook_dir = tempfile.mkdtemp()
 
966
        orig_opt_dir = apport.report._opt_dir
 
967
        apport.report._opt_dir = tempfile.mkdtemp()
 
968
        try:
 
969
            opt_hook_dir = os.path.join(apport.report._opt_dir,
 
970
                                        'foolabs.example.com', 'foo', 'share',
 
971
                                        'apport', 'package-hooks')
 
972
            os.makedirs(opt_hook_dir)
 
973
            with open(os.path.join(opt_hook_dir, 'source_foo.py'), 'w') as fd:
 
974
                fd.write('''def add_info(report, ui):
 
975
    report['SourceHook'] = '1'
 
976
''')
 
977
            with open(os.path.join(opt_hook_dir, 'foo-bin.py'), 'w') as fd:
 
978
                fd.write('''def add_info(report, ui):
 
979
    report['BinHook'] = '1'
 
980
''')
 
981
 
 
982
            r = apport.report.Report()
 
983
            r['Package'] = 'foo-bin 0.2'
 
984
            r['SourcePackage'] = 'foo'
 
985
            r['ExecutablePath'] = '%s/foolabs.example.com/foo/bin/frob' % apport.report._opt_dir
 
986
 
 
987
            self.assertEqual(r.add_hooks_info('fake_ui'), False)
 
988
            self.assertEqual(r['SourceHook'], '1')
 
989
        finally:
 
990
            shutil.rmtree(apport.report._opt_dir)
 
991
            shutil.rmtree(apport.report._hook_dir)
 
992
            shutil.rmtree(apport.report._common_hook_dir)
 
993
            apport.report._hook_dir = orig_hook_dir
 
994
            apport.report._common_hook_dir = orig_common_hook_dir
 
995
            apport.report._opt_dir = orig_opt_dir
 
996
 
959
997
    def test_ignoring(self):
960
998
        '''mark_ignore() and check_ignored().'''
961
999