~ubuntu-branches/ubuntu/precise/software-properties/precise-proposed-201312210113

« back to all changes in this revision

Viewing changes to tests/test_dbus.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2011-10-10 10:55:45 UTC
  • Revision ID: james.westby@ubuntu.com-20111010105545-rhs6j3c1tjkup5e2
Tags: 0.81.10
* softwareproperties/dbus/SoftwarePropertiesDBus.py, tests/test_dbus.py:
  - fix crash when there are unicode comments in the sources.list 
    file (LP: #820028). Dbus always sends us a dbus.String which is
    type unicode, but python-apt expects utf8 encoded str

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
 
2
# -*- coding: utf-8 -*-
2
3
 
3
4
from gi.repository import Gtk, GObject
4
5
 
19
20
from softwareproperties import (
20
21
    UPDATE_INST_SEC, UPDATE_DOWNLOAD, UPDATE_NOTIFY)
21
22
 
 
23
def get_test_source_line():
 
24
    distro_release = get_distro_release()
 
25
    return "deb http://archive.ubuntu.com/ubuntu %s main restricted #"\
 
26
           " comment with unicode äöü" % distro_release
 
27
 
22
28
def get_distro_release():
23
29
    return subprocess.check_output(["lsb_release", "-c", "-s"]).strip()
24
30
 
25
31
def create_sources_list():
26
 
    distro_release = get_distro_release()
27
 
    s = "deb http://archive.ubuntu.com/ubuntu %s main restricted\n" % distro_release
 
32
    s = get_test_source_line() + "\n"
28
33
    f=open("./aptroot/etc/apt/sources.list", "w")
29
34
    f.write(s)
30
35
    f.close()
135
140
        
136
141
    def test_toggle_source(self):
137
142
        # test toggle
138
 
        source = "deb http://archive.ubuntu.com/ubuntu %s main restricted" % self.distro_release
 
143
        source = get_test_source_line()
139
144
        res = self.iface.ToggleSourceUse(source)
140
145
        sourceslist =  open("./aptroot/etc/apt/sources.list").read()
141
146
        self._debug_sourceslist("10")
151
156
 
152
157
    def test_replace_entry(self):
153
158
        # test toggle
154
 
        source = "deb http://archive.ubuntu.com/ubuntu %s main restricted" % self.distro_release
 
159
        source = get_test_source_line()
155
160
        source_new = "deb http://xxx/ %s" % self.distro_release
156
161
        res = self.iface.ReplaceSourceEntry(source, source_new)
157
162
        sourceslist =  open("./aptroot/etc/apt/sources.list").read()