~ubuntu-branches/ubuntu/natty/aptdaemon/natty-security

« back to all changes in this revision

Viewing changes to tests/test_unicodedecoding.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-04-12 13:25:49 UTC
  • mfrom: (1.1.47 upstream)
  • Revision ID: james.westby@ubuntu.com-20110412132549-8rc74dfr01jil7vm
Tags: 0.41+bzr629-0ubuntu1
* New bzr bugfix snapshot:
  - improve utf8 encoding handling tests
  - lp:~mvo/aptdaemon/relax-lintian-checks merged
  - improve terminal handling, LP: #741260, #693290, #741260,  
    #738056,  #742780, #743818, #744444, #746727, #747539, #753700,
    #753762, #753927, #754134, #754174, #754205, #754206, #754220
  - fix refactoring lefovers (LP: #752220)
  - don't segfault if we cannot read the status of the process holding 
    a lock (LP: #745517)
* debian/patches/01_relax_lintian_checks.patch:
  - removed, taken upstream
* debian/patches/02_fix_unicode_in_convert_struct.patch:
  - removed, taken usptream
* debian/patches/04_import_logging.patch:
  - removed, fixed usptream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
# Copyright (C) 2011 Michael Vogt <mvo@ubuntu.com>
 
4
#
 
5
# Licensed under the GNU General Public License Version 2
 
6
#
 
7
# This program is free software; you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation; either version 2 of the License, or
 
10
# at your option) any later version.
 
11
#
 
12
# This program is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with this program; if not, write to the Free Software
 
19
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
# Licensed under the GNU General Public License Version 2
 
21
 
 
22
"""Regression test for a unicode decoding error in the status_details,
 
23
progress_download or error_properties attributes of the transaction,
 
24
see LP #724735.
 
25
"""
 
26
 
 
27
__author__  = "Michael Vogt <mvo@glatzor.de>"
 
28
 
 
29
import os
 
30
import unittest2
 
31
 
 
32
import dbus
 
33
 
 
34
from aptdaemon.core import Transaction
 
35
from aptdaemon.errors import TransactionFailed
 
36
from aptdaemon.test import AptDaemonTestCase, Chroot
 
37
 
 
38
 
 
39
class TestUnicodeDecoding(AptDaemonTestCase):
 
40
 
 
41
    """Test the workaround."""
 
42
 
 
43
    def setUp(self):
 
44
        self.chroot = Chroot()
 
45
        self.chroot.setup()
 
46
        self.addCleanup(self.chroot.remove)
 
47
        self.start_dbus_daemon()
 
48
        self.dbus = dbus.bus.BusConnection(self.dbus_address)
 
49
        self.trans = Transaction("role-test", None, os.getuid(),
 
50
                                 "org.debian.apt.test", bus=self.dbus)
 
51
 
 
52
    def test(self):
 
53
        # ensure we don't crash regardless if str or unicode is passed here
 
54
        self.trans.status_details = "äää"
 
55
        self.trans.status_details = u"äää"
 
56
 
 
57
        self.trans.progress_download = ("äö", "ß", "üöä", 1L, 2L, "ö")
 
58
        self.trans.progress_download = (u"äö", u"ß", u"üöä", 1L, 2L, u"ö")
 
59
 
 
60
        self.trans.error = TransactionFailed("ERROR_TEST", "Mixed ä %s", u"öä")
 
61
        self.trans.error = TransactionFailed("ERROR_TEST", u"Mixed ü %s", "öä")
 
62
        self.trans.error = TransactionFailed("ERROR_TEST", "Str ä %s", "öä")
 
63
        self.trans.error = TransactionFailed("ERROR_TEST", u"Uni ä %s", u"öä")
 
64
 
 
65
 
 
66
if __name__ == "__main__":
 
67
    unittest2.main()
 
68
 
 
69
# vim: ts=4 et sts=4