~ubuntu-branches/ubuntu/precise/apport/precise

« back to all changes in this revision

Viewing changes to test/test_report.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-03-07 14:47:31 UTC
  • mfrom: (148.1.55)
  • Revision ID: package-import@ubuntu.com-20120307144731-vnoff16v0fwhxh0h
Tags: 1.94.1-0ubuntu1
* New upstream bug fix release. Changes since our previous snapshot:
  - apport-cli: Consistently handle unicode vs. byte arrays. (LP: #946207)
  - report.py, anonymize(): Fix crash when the hostname or user name contain
    non-ASCII characters. (LP: #945230)
  - packaging-apt-dpkg.py: Fix UnicodeDecodeError on unexpected md5sum output.
    (LP: #921037)
  - apport-gtk: Fix handling of non-ASCII strings in message dialogs.
    (LP: #620579)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# coding: UTF-8
1
2
import unittest, shutil, time, tempfile, os, subprocess, grp, atexit, re
2
3
 
3
4
import apport.report
1669
1670
        self.assertEqual(pr.crash_signature(), '/bin/foo:11:h:main')
1670
1671
        self.assertEqual(pr.standard_title(), 'foo crashed with SIGSEGV in h()')
1671
1672
 
 
1673
    def test_nonascii_data(self):
 
1674
        '''methods get along with non-ASCII data'''
 
1675
 
 
1676
        # fake os.uname() into reporting a non-ASCII name
 
1677
        uname = os.uname()
 
1678
        uname = (uname[0], 't♪x', uname[2], uname[3], uname[4])
 
1679
        orig_uname = os.uname
 
1680
        os.uname = lambda: uname
 
1681
 
 
1682
        try:
 
1683
            pr = apport.report.Report()
 
1684
            pr['ProcUnicodeValue'] = u'ä %s ♥ ' % uname[1].decode('UTF-8')
 
1685
            pr['ProcByteArrayValue'] = b'ä %s ♥ ' % uname[1]
 
1686
 
 
1687
            pr.anonymize()
 
1688
 
 
1689
            self.assertEqual(pr['ProcUnicodeValue'], u'ä hostname ♥ ')
 
1690
            self.assertEqual(pr['ProcByteArrayValue'], b'ä hostname ♥ ')
 
1691
        finally:
 
1692
            os.uname = orig_uname
 
1693
 
1672
1694
    def test_address_to_offset(self):
1673
1695
        '''_address_to_offset()'''
1674
1696