[Reportbug-commits] [reportbug] 08/32: port reportbug.utils to py3k
Sandro Tosi
morph at moszumanska.debian.org
Thu Dec 1 01:36:51 UTC 2016
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository reportbug.
commit 8a01f85182490cd60e0ea7a4917cfb21e014c132
Author: Sandro Tosi <morph at debian.org>
Date: Fri Nov 25 14:52:13 2016 -0500
port reportbug.utils to py3k
---
reportbug/utils.py | 126 +++++++++++++++++++------------------------
test/test_utils.py | 154 ++++++++++++++++++++++++++---------------------------
2 files changed, 133 insertions(+), 147 deletions(-)
diff --git a/reportbug/utils.py b/reportbug/utils.py
index 165e2a4..0995b49 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -27,20 +27,20 @@ import platform
try:
import pwd
- from tempfiles import TempFile, tempfile_prefix, cleanup_temp_file
-except ImportError, e:
+ from .tempfiles import TempFile, tempfile_prefix, cleanup_temp_file
+except ImportError as e:
if platform.system() == 'Windows':
pass
else:
- print e
+ print(e)
sys.exit(1)
-import commands
import shlex
-import rfc822
+import email
import socket
import subprocess
+import pipes
-from urlutils import open_url
+from .urlutils import open_url
from string import ascii_letters, digits
# Paths for dpkg
@@ -66,13 +66,13 @@ MODES = {'novice': 'Offer simple prompts, bypassing technical questions.',
'Debian\'s policies and operating procedures.'}
MODELIST = ['novice', 'standard', 'advanced', 'expert']
for mode in MODELIST:
- exec 'MODE_%s=%d' % (mode.upper(), MODELIST.index(mode))
+ exec('MODE_%s=%d' % (mode.upper(), MODELIST.index(mode)))
del mode
# moved here since it needs the MODE_* vars to be defined
-import debbugs
+from . import debbugs
# it needs to be imported after debbugs
-import ui.text_ui as ui
+from .ui import text_ui as ui
from reportbug.ui import AVAILABLE_UIS
@@ -99,7 +99,7 @@ CODENAME2SUITE = {'squeeze': 'oldoldstable',
'buster': 'next-testing',
'sid': 'unstable',
'experimental': 'experimental'}
-SUITE2CODENAME = dict([(suite, codename) for codename, suite in CODENAME2SUITE.items()])
+SUITE2CODENAME = dict([(suite, codename) for codename, suite in list(CODENAME2SUITE.items())])
def realpath(filename):
@@ -115,7 +115,7 @@ def realpath(filename):
resolved = os.readlink(component)
(dir, file) = os.path.split(component)
resolved = os.path.normpath(os.path.join(dir, resolved))
- newpath = apply(os.path.join, [resolved] + bits[i:])
+ newpath = os.path.join(*[resolved] + bits[i:])
return realpath(newpath)
return filename
@@ -171,7 +171,7 @@ def glob_escape(filename):
def search_pipe(searchfile, use_dlocate=True):
- arg = commands.mkarg(searchfile)
+ arg = pipes.quote(searchfile)
if use_dlocate and os.path.exists('/usr/bin/dlocate'):
pipe = os.popen('COLUMNS=79 dlocate -S %s 2>/dev/null' % arg)
else:
@@ -239,7 +239,7 @@ def find_rewritten(username):
for filename in ['/etc/email-addresses']:
if os.path.exists(filename):
try:
- fp = file(filename)
+ fp = open(filename)
except IOError:
continue
for line in fp:
@@ -251,7 +251,7 @@ def find_rewritten(username):
if name.strip() == username:
return alias.strip()
except ValueError:
- print 'Invalid entry in %s' % filename
+ print('Invalid entry in %s' % filename)
return None
@@ -272,8 +272,7 @@ def check_email_addr(addr):
def get_email_addr(addr):
- addr = rfc822.AddressList(addr)
- return addr.addresslist[0]
+ return email.utils.getaddresses([addr,])[0]
def get_email(email='', realname=''):
@@ -290,7 +289,7 @@ def get_user_id(email='', realname='', charset='utf-8'):
if '@' not in email:
if os.path.exists('/etc/mailname'):
- domainname = file('/etc/mailname').readline().strip()
+ domainname = open('/etc/mailname').readline().strip()
else:
domainname = socket.getfqdn()
@@ -311,17 +310,11 @@ def get_user_id(email='', realname='', charset='utf-8'):
if not realname:
return email
- # Decode the realname from the charset -
- # but only if it is not already in Unicode
- if isinstance(realname, str):
- realname = realname.decode(charset, 'replace')
-
if re.match(r'[\w\s]+$', realname):
- return u'%s <%s>' % (realname, email)
+ return '%s <%s>' % (realname, email)
+
+ addr = email.utils.formataddr((realname, email))
- addr = rfc822.dump_address_pair((realname, email))
- if isinstance(addr, str):
- addr = addr.decode('utf-8', 'replace')
return addr
@@ -363,17 +356,14 @@ def get_package_status(package, avail=False):
except OSError:
os.chdir('/')
- packarg = commands.mkarg(package)
+ packarg = pipes.quote(package)
if avail:
- output = commands.getoutput(
+ output = subprocess.getoutput(
"COLUMNS=79 dpkg --print-avail %s 2>/dev/null" % packarg)
else:
- output = commands.getoutput(
+ output = subprocess.getoutput(
"COLUMNS=79 dpkg --status %s 2>/dev/null" % packarg)
- # dpkg output is in UTF-8 format
- output = output.decode('utf-8', 'replace')
-
for line in output.split(os.linesep):
line = line.rstrip()
if not line:
@@ -474,8 +464,8 @@ class AvailDB(object):
def __iter__(self):
return self
- def next(self):
- chunk = u''
+ def __next__(self):
+ chunk = ''
while True:
if self.popenob:
if self.popenob.returncode:
@@ -487,7 +477,7 @@ class AvailDB(object):
if line == '\n':
return chunk
- chunk += line.decode('utf-8', 'replace')
+ chunk += str(line)
if chunk:
return chunk
@@ -515,7 +505,7 @@ def get_dpkg_database():
if fp:
return AvailDB(fp=fp)
except IOError:
- print >> sys.stderr, 'Unable to open', STATUSDB
+ print('Unable to open', STATUSDB, file=sys.stderr)
sys.exit(1)
@@ -526,8 +516,7 @@ def get_avail_database():
def available_package_description(package):
- data = commands.getoutput('apt-cache show' + commands.mkarg(package))
- data = data.decode('utf-8', 'replace')
+ data = subprocess.getoutput('apt-cache show ' + pipes.quote(package))
descre = re.compile('^Description(?:-.*)?: (.*)$')
for line in data.split('\n'):
m = descre.match(line)
@@ -539,8 +528,7 @@ def available_package_description(package):
def get_source_name(package):
packages = []
- data = commands.getoutput('apt-cache showsrc' + commands.mkarg(package))
- data = data.decode('utf-8', 'replace')
+ data = subprocess.getoutput('apt-cache showsrc ' + pipes.quote(package))
packre = re.compile(r'^Package: (.*)$')
for line in data.split('\n'):
m = packre.match(line)
@@ -554,8 +542,7 @@ def get_source_package(package):
retlist = []
found = {}
- data = commands.getoutput('apt-cache showsrc' + commands.mkarg(package))
- data = data.decode('utf-8', 'replace')
+ data = subprocess.getoutput('apt-cache showsrc ' + pipes.quote(package))
binre = re.compile(r'^Binary: (.*)$')
for line in data.split('\n'):
m = binre.match(line)
@@ -597,7 +584,7 @@ def get_package_info(packages, skip_notfound=False):
r')(?:$|,\s+)' + pkgname + '*$'
]
- groups = groupfor.values()
+ groups = list(groupfor.values())
found = {}
searchobs = [re.compile(x, re.MULTILINE) for x in searchbits]
@@ -680,7 +667,7 @@ def get_dependency_info(package, depends, rel="depends on"):
if not packs[pkg][4]:
packs[pkg] = info
- deplist = packs.values()
+ deplist = list(packs.values())
deplist.sort()
deplist2 = []
@@ -717,12 +704,12 @@ def get_changed_config_files(conffiles, nocompress=False):
changed = []
for (filename, md5sum) in conffiles:
try:
- fp = file(filename)
- except IOError, msg:
+ fp = open(filename)
+ except IOError as msg:
confinfo[filename] = msg
continue
- filemd5 = commands.getoutput('md5sum ' + commands.mkarg(filename)).split()[0]
+ filemd5 = subprocess.getoutput('md5sum ' + pipes.quote(filename)).split()[0]
if filemd5 == md5sum:
continue
@@ -739,7 +726,7 @@ def get_changed_config_files(conffiles, nocompress=False):
thisinfo += line
- confinfo[filename] = thisinfo.decode('utf-8', 'replace')
+ confinfo[filename] = thisinfo
return confinfo, changed
@@ -750,7 +737,7 @@ DISTORDER = ['oldstable', 'stable', 'testing', 'unstable', 'experimental']
def get_debian_release_info():
debvers = debinfo = verfile = warn = ''
dists = []
- output = commands.getoutput('apt-cache policy 2>/dev/null')
+ output = subprocess.getoutput('apt-cache policy 2>/dev/null')
if output:
mre = re.compile('\s+(\d+)\s+.*$\s+release\s.*o=(Ubuntu|Debian|Debian Ports),a=([^,]+),', re.MULTILINE)
found = {}
@@ -765,7 +752,7 @@ def get_debian_release_info():
found[(pri, dist, distname)] = True
if found:
- dists = found.keys()
+ dists = list(found.keys())
dists.sort()
dists.reverse()
dists = [(x[0], x[2]) for x in dists]
@@ -776,7 +763,7 @@ def get_debian_release_info():
verfile = fob.readline().strip()
fob.close()
except IOError:
- print >> sys.stderr, 'Unable to open /etc/debian_version'
+ print('Unable to open /etc/debian_version', file=sys.stderr)
if verfile:
debinfo += 'Debian Release: ' + verfile + '\n'
@@ -794,11 +781,11 @@ def get_debian_release_info():
def lsb_release_info():
- return commands.getoutput('lsb_release -a 2>/dev/null') + '\n'
+ return subprocess.getoutput('lsb_release -a 2>/dev/null') + '\n'
def get_arch():
- arch = commands.getoutput('COLUMNS=79 dpkg --print-architecture 2>/dev/null')
+ arch = subprocess.getoutput('COLUMNS=79 dpkg --print-architecture 2>/dev/null')
if not arch:
un = os.uname()
arch = un[4]
@@ -809,7 +796,7 @@ def get_arch():
def get_multiarch():
- out = commands.getoutput('COLUMNS=79 dpkg --print-foreign-architectures 2>/dev/null')
+ out = subprocess.getoutput('COLUMNS=79 dpkg --print-foreign-architectures 2>/dev/null')
return ', '.join(out.splitlines())
@@ -819,7 +806,7 @@ def generate_blank_report(package, pkgversion, severity, justification,
subject='', tags='', body='', mode=MODE_EXPERT,
pseudos=None, debsumsoutput=None, issource=False):
# For now...
- import bugreport
+ from . import bugreport
sysinfo = (package not in ('wnpp', 'ftp.debian.org'))
@@ -832,7 +819,7 @@ def generate_blank_report(package, pkgversion, severity, justification,
system=system, depinfo=depinfo, sysinfo=sysinfo,
confinfo=confinfo, incfiles=incfiles,
debsumsoutput=debsumsoutput, issource=issource)
- return unicode(rep)
+ return str(rep)
def get_cpu_cores():
@@ -840,7 +827,7 @@ def get_cpu_cores():
try:
fob = open('/proc/cpuinfo')
except IOError:
- print >> sys.stderr, 'Unable to open /proc/cpuinfo'
+ print('Unable to open /proc/cpuinfo', file=sys.stderr)
return 0
for line in fob:
@@ -888,7 +875,7 @@ class Mua:
mua = self.command
if '%s' not in mua:
mua += ' %s'
- return ui.system(mua % commands.mkarg(filename)[1:])
+ return ui.system(mua % pipes.quote(filename)[1:])
def get_name(self):
return self.name
@@ -905,7 +892,7 @@ class Gnus(Mua):
(load-file "/usr/share/reportbug/reportbug.el")
(tfheen-reportbug-insert-template "%s"))"""
filename = re.sub("[\"\\\\]", "\\\\\\g<0>", filename)
- elisp = commands.mkarg(elisp % filename)
+ elisp = pipes.quote(elisp % filename)
return ui.system("emacsclient --no-wait --eval %s 2>/dev/null"
" || emacs --eval %s" % (elisp, elisp))
@@ -994,8 +981,8 @@ def parse_config_files():
for filename in FILES:
if os.path.exists(filename):
try:
- lex = our_lex(file(filename), posix=True)
- except IOError, msg:
+ lex = our_lex(open(filename), posix=True)
+ except IOError as msg:
continue
lex.wordchars = lex.wordchars + '-.@/:<>'
@@ -1007,7 +994,7 @@ def parse_config_files():
args['sendto'] = token
elif token == 'severity':
token = lex.get_token().lower()
- if token in debbugs.SEVERITIES.keys():
+ if token in list(debbugs.SEVERITIES.keys()):
args['severity'] = token
elif token == 'header':
args['headers'] = args.get('headers', []) + [lex.get_token()]
@@ -1026,7 +1013,7 @@ def parse_config_files():
'smtppasswd', 'justification', 'keyid',
'mbox_reader_cmd'):
bit = lex.get_token()
- args[token] = bit.decode('utf-8', 'replace')
+ args[token] = bit
elif token in ('no-smtptls', 'smtptls'):
args['smtptls'] = (token == 'smtptls')
elif token == 'sign':
@@ -1039,15 +1026,15 @@ def parse_config_files():
args['sign'] = ''
elif token == 'ui':
token = lex.get_token().lower()
- if token in AVAILABLE_UIS.keys():
+ if token in list(AVAILABLE_UIS.keys()):
args['interface'] = token
elif token == 'mode':
arg = lex.get_token().lower()
- if arg in MODES.keys():
+ if arg in list(MODES.keys()):
args[token] = arg
elif token == 'bts':
token = lex.get_token().lower()
- if token in debbugs.SYSTEMS.keys():
+ if token in list(debbugs.SYSTEMS.keys()):
args['bts'] = token
elif token == 'mirror':
args['mirrors'] = args.get('mirrors', []) + [lex.get_token()]
@@ -1087,7 +1074,7 @@ def parse_bug_control_file(filename):
submitas = submitto = None
reportwith = []
supplemental = []
- fh = file(filename)
+ fh = open(filename)
for line in fh:
line = line.strip()
parts = line.split(': ')
@@ -1245,8 +1232,8 @@ def exec_and_parse_bugscript(handler, bugscript):
fh, filename = TempFile()
fh.close()
- rc = os.system('LC_ALL=C %s %s %s' % (handler, commands.mkarg(bugscript),
- commands.mkarg(filename)))
+ rc = os.system('LC_ALL=C %s %s %s' % (handler, pipes.quote(bugscript),
+ pipes.quote(filename)))
isheaders = False
ispseudoheaders = False
@@ -1280,7 +1267,6 @@ def exec_and_parse_bugscript(handler, bugscript):
fp.close()
cleanup_temp_file(filename)
- text = text.decode('utf-8', 'replace')
return (rc, headers, pseudoheaders, text, attachments)
diff --git a/test/test_utils.py b/test/test_utils.py
index d9ccbdf..280e495 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -1,4 +1,4 @@
-import unittest2
+import unittest
from reportbug import utils
import os.path
@@ -6,18 +6,18 @@ import platform
from nose.plugins.attrib import attr
import debianbts
import mock
-import commands
+import subprocess
import subprocess
-class TestUtils(unittest2.TestCase):
+class TestUtils(unittest.TestCase):
def test_modes_and_modelist(self):
"""Check MODES items and MODELIST are in sync"""
- self.assertItemsEqual(utils.MODES.keys(), utils.MODELIST)
+ self.assertCountEqual(list(utils.MODES.keys()), utils.MODELIST)
-class TestEmail(unittest2.TestCase):
+class TestEmail(unittest.TestCase):
def test_check_email_addr(self):
real_addr = 'reportbug-maint at lists.alioth.debian.org'
@@ -66,10 +66,10 @@ class TestEmail(unittest2.TestCase):
self.assertIn(mail, addr)
def test_find_rewritten(self):
- unittest2.skip("Is utils.find_rewritten actually useful to someone? deprecate it?")
+ unittest.skip("Is utils.find_rewritten actually useful to someone? deprecate it?")
-class TestPackages(unittest2.TestCase):
+class TestPackages(unittest.TestCase):
def test_get_package_status(self):
status = utils.get_package_status('non-existing-package')
@@ -155,16 +155,16 @@ class TestPackages(unittest2.TestCase):
pkg = 'test_bts791577'
- expected_conffiles = [u'/etc/reportbug.conf',
- u'/etc/reportbug with spaces.conf',
- u'/etc/reportbug.conf.obsolete',
- u'/etc/reportbug with spaces and obsolete.conf']
+ expected_conffiles = ['/etc/reportbug.conf',
+ '/etc/reportbug with spaces.conf',
+ '/etc/reportbug.conf.obsolete',
+ '/etc/reportbug with spaces and obsolete.conf']
- __save = commands.getoutput
- commands.getoutput = mock.MagicMock(return_value=pkgstatus)
+ __save = subprocess.getoutput
+ subprocess.getoutput = mock.MagicMock(return_value=pkgstatus)
result = utils.get_package_status(pkg)
conffile = [x[0] for x in result[4]]
- commands.getoutput = __save
+ subprocess.getoutput = __save
del __save
self.assertListEqual(conffile, expected_conffiles)
@@ -234,33 +234,33 @@ Version: 6.6.3
"""
pkg = 'reportbug'
- __save = commands.getoutput
- commands.getoutput = mock.MagicMock(return_value=pkginfo % 'Description')
+ __save = subprocess.getoutput
+ subprocess.getoutput = mock.MagicMock(return_value=pkginfo % 'Description')
result = utils.available_package_description(pkg)
- self.assertEqual(u'reports bugs in the Debian distribution', result)
- commands.getoutput = mock.MagicMock(return_value=pkginfo % 'Description-en')
+ self.assertEqual('reports bugs in the Debian distribution', result)
+ subprocess.getoutput = mock.MagicMock(return_value=pkginfo % 'Description-en')
result = utils.available_package_description(pkg)
- self.assertEqual(u'reports bugs in the Debian distribution', result)
- commands.getoutput = __save
+ self.assertEqual('reports bugs in the Debian distribution', result)
+ subprocess.getoutput = __save
del __save
- __save = commands.getoutput
- commands.getoutput = mock.MagicMock(return_value=pkginfo % 'Description')
+ __save = subprocess.getoutput
+ subprocess.getoutput = mock.MagicMock(return_value=pkginfo % 'Description')
result = utils.get_package_status(pkg)
- self.assertEqual(u'reports bugs in the Debian distribution', result[11])
- commands.getoutput = mock.MagicMock(return_value=pkginfo % 'Description-en')
+ self.assertEqual('reports bugs in the Debian distribution', result[11])
+ subprocess.getoutput = mock.MagicMock(return_value=pkginfo % 'Description-en')
result = utils.get_package_status(pkg)
- self.assertEqual(u'reports bugs in the Debian distribution', result[11])
- commands.getoutput = __save
+ self.assertEqual('reports bugs in the Debian distribution', result[11])
+ subprocess.getoutput = __save
del __save
__save = utils.get_dpkg_database
utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description', ])
result = utils.get_package_info([((pkg,), pkg)])
- self.assertEqual(u'reports bugs in the Debian distribution', result[0][3])
+ self.assertEqual('reports bugs in the Debian distribution', result[0][3])
utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description-en', ])
result = utils.get_package_info([((pkg,), pkg)])
- self.assertEqual(u'reports bugs in the Debian distribution', result[0][3])
+ self.assertEqual('reports bugs in the Debian distribution', result[0][3])
utils.get_dpkg_database = __save
del __save
@@ -272,19 +272,19 @@ Version: 6.6.3
def test_get_avail_database(self):
avail_db = utils.get_avail_database()
- entry = avail_db.next()
+ entry = next(avail_db)
self.assertIsNotNone(entry)
def test_available_package_description(self):
descr = utils.available_package_description('reportbug')
- self.assertEquals(descr, 'reports bugs in the Debian distribution')
+ self.assertEqual(descr, 'reports bugs in the Debian distribution')
descr = utils.available_package_description('reportbug-bugfree')
self.assertIsNone(descr)
-class TestSourcePackages(unittest2.TestCase):
- # @unittest2.skip("Too slow")
+class TestSourcePackages(unittest.TestCase):
+ # @unittest.skip("Too slow")
def test_get_source_name(self):
binpkg = 'python-reportbug'
src = utils.get_source_name(binpkg)
@@ -293,18 +293,18 @@ class TestSourcePackages(unittest2.TestCase):
src = utils.get_source_name('reportbug-bugfree')
self.assertIsNone(src)
- # @unittest2.skip("Too slow")
+ # @unittest.skip("Too slow")
def test_get_source_package(self):
src = 'reportbug'
binpkgs = utils.get_source_package(src)
- self.assertItemsEqual([bin[0] for bin in binpkgs], ['python-reportbug', 'reportbug'])
+ self.assertCountEqual([bin[0] for bin in binpkgs], ['python-reportbug', 'reportbug'])
bin = 'python-reportbug'
binpkgs_frombin = utils.get_source_package(bin)
self.assertEqual(binpkgs, binpkgs_frombin)
-class TestSystemInformation(unittest2.TestCase):
+class TestSystemInformation(unittest.TestCase):
def test_get_cpu_cores(self):
cores = utils.get_cpu_cores()
self.assertGreaterEqual(cores, 1)
@@ -319,21 +319,21 @@ class TestSystemInformation(unittest2.TestCase):
self.assertIn(platform.release(), package)
def test_get_multiarch(self):
- orig = commands.getoutput
+ orig = subprocess.getoutput
- commands.getoutput = mock.MagicMock(return_value='')
+ subprocess.getoutput = mock.MagicMock(return_value='')
multiarch = utils.get_multiarch()
self.assertEqual(multiarch, '')
- commands.getoutput = mock.MagicMock(return_value='i386')
+ subprocess.getoutput = mock.MagicMock(return_value='i386')
multiarch = utils.get_multiarch()
self.assertEqual(multiarch, 'i386')
- commands.getoutput = mock.MagicMock(return_value='i386\namd64')
+ subprocess.getoutput = mock.MagicMock(return_value='i386\namd64')
multiarch = utils.get_multiarch()
- self.assertItemsEqual(multiarch.split(', '), ['i386', 'amd64'])
+ self.assertCountEqual(multiarch.split(', '), ['i386', 'amd64'])
- commands.getoutput = orig
+ subprocess.getoutput = orig
def test_get_init_system(self):
__save = os.path.isdir
@@ -362,7 +362,7 @@ class TestSystemInformation(unittest2.TestCase):
del __save2
-class TestMua(unittest2.TestCase):
+class TestMua(unittest.TestCase):
def test_mua_is_supported(self):
for mua in ('mh', 'nmh', 'gnus', 'mutt', 'claws-mail'):
@@ -384,7 +384,7 @@ class TestMua(unittest2.TestCase):
self.assertEqual(utils.mua_name('mua-of-my-dreams'), 'mua-of-my-dreams')
-class TestBugreportBody(unittest2.TestCase):
+class TestBugreportBody(unittest.TestCase):
def test_get_dependency_info(self):
pkg = 'reportbug'
@@ -449,7 +449,7 @@ Architecture: amd64 (x86_64)
Kernel: Linux 2.6.31-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash"""
- header = [u'X-Debbugs-CC: reportbug at packages.qa.debian.org']
+ header = ['X-Debbugs-CC: reportbug at packages.qa.debian.org']
pseudos = ['Morph: cool', 'Control: testcontrol1', 'Control: testcontrol2']
rtype = 'debbugs'
body, headers, pseudo = utils.cleanup_msg(message, header, pseudos,
@@ -510,7 +510,7 @@ Shell: /bin/sh linked to /bin/bash"""
exinfo={'123456': ''})
-class TestConfig(unittest2.TestCase):
+class TestConfig(unittest.TestCase):
# Use an "internal" file for testing
def setUp(self):
self._FILES = utils.FILES
@@ -526,33 +526,33 @@ class TestConfig(unittest2.TestCase):
'check_uid': False,
'debconf': False,
'dontquery': False,
- 'editor': u'emacs -nw',
- 'email': u'reportbug-maint at lists.alioth.debian.org',
- 'envelopefrom': u'reportbug-maint at lists.alioth.debian.org',
+ 'editor': 'emacs -nw',
+ 'email': 'reportbug-maint at lists.alioth.debian.org',
+ 'envelopefrom': 'reportbug-maint at lists.alioth.debian.org',
'headers': ['X-Reportbug-Testsuite: this is the test suite'],
- 'http_proxy': u'http://proxy.example.com:3128/',
- 'interface': 'gtk2',
- 'keyid': u'deadbeef',
+ 'http_proxy': 'http://proxy.example.com:3128/',
+ 'interface': 'text',
+ 'keyid': 'deadbeef',
'max_attachment_size': 1024000,
- 'mbox_reader_cmd': u'mutt -f %s',
+ 'mbox_reader_cmd': 'mutt -f %s',
'mirrors': ['this_is_a_bts_mirror'],
'mode': 'novice',
- 'mta': u'/usr/sbin/sendmail',
+ 'mta': '/usr/sbin/sendmail',
'nocc': False,
'nocompress': False,
'noconf': False,
'offline': True,
'paranoid': True,
'query_src': False,
- 'realname': u'Reportbug Maintainers',
- 'replyto': u'We dont care <dev at null.org>',
+ 'realname': 'Reportbug Maintainers',
+ 'replyto': 'We dont care <dev at null.org>',
'sendto': 'submit',
'severity': 'normal',
'sign': 'gpg',
- 'smtphost': u'reportbug.debian.org:587',
- 'smtppasswd': u'James Bond',
+ 'smtphost': 'reportbug.debian.org:587',
+ 'smtppasswd': 'James Bond',
'smtptls': True,
- 'smtpuser': u'Bond',
+ 'smtpuser': 'Bond',
'template': True,
'verify': True}
@@ -573,22 +573,22 @@ class TestConfig(unittest2.TestCase):
self.assertEqual(realname, 'Paul "TBBle" Hampson')
-class TestControl(unittest2.TestCase):
+class TestControl(unittest.TestCase):
def test_parse_bug_control_file(self):
ctrl_file = os.path.dirname(__file__) + '/data/control'
submitas, submitto, reportwith, supplemental = \
utils.parse_bug_control_file(ctrl_file)
- self.assertEquals(submitas, 'reportbug2')
- self.assertEquals(submitto, 'reportbug-maint at lists.alioth.debian.org')
+ self.assertEqual(submitas, 'reportbug2')
+ self.assertEqual(submitto, 'reportbug-maint at lists.alioth.debian.org')
self.assertIn('python', reportwith)
self.assertIn('perl', reportwith)
self.assertIn('python', supplemental)
self.assertIn('perl', supplemental)
-class TestPaths(unittest2.TestCase):
+class TestPaths(unittest.TestCase):
def test_search_path_for(self):
p = 'not-existing'
res = utils.search_path_for(p)
@@ -596,24 +596,24 @@ class TestPaths(unittest2.TestCase):
p = '/tmp'
res = utils.search_path_for(p)
- self.assertEquals(p, res)
+ self.assertEqual(p, res)
p = 'dpkg'
res = utils.search_path_for(p)
- self.assertEquals(res, '/usr/bin/dpkg')
+ self.assertEqual(res, '/usr/bin/dpkg')
-class TestEditor(unittest2.TestCase):
+class TestEditor(unittest.TestCase):
def test_which_editor(self):
res = utils.which_editor()
self.assertIsNotNone(res)
e = 'reportbug-editor'
res = utils.which_editor(e)
- self.assertEquals(e, res)
+ self.assertEqual(e, res)
-class TestSearch(unittest2.TestCase):
+class TestSearch(unittest.TestCase):
def test_search_pipe(self):
f = 'reportbug'
@@ -622,7 +622,7 @@ class TestSearch(unittest2.TestCase):
res = pipe.readlines()
pipe.close()
- self.assertEquals(dloc, dlocate)
+ self.assertEqual(dloc, dlocate)
self.assertGreater(len(res), 0)
dlocate = False
@@ -630,35 +630,35 @@ class TestSearch(unittest2.TestCase):
res = pipe.readlines()
pipe.close()
- self.assertEquals(dloc, dlocate)
+ self.assertEqual(dloc, dlocate)
self.assertGreater(len(res), 0)
-class TestDpkg(unittest2.TestCase):
+class TestDpkg(unittest.TestCase):
def test_query_dpkg_for(self):
p = 'reportbug'
dlocate = True
res = utils.query_dpkg_for(p, dlocate)
- self.assertEquals(res[0], p)
- self.assertGreater(len(res[1].keys()), 0)
+ self.assertEqual(res[0], p)
+ self.assertGreater(len(list(res[1].keys())), 0)
dlocate = False
res = utils.query_dpkg_for(p, dlocate)
- self.assertEquals(res[0], p)
- self.assertGreater(len(res[1].keys()), 0)
+ self.assertEqual(res[0], p)
+ self.assertGreater(len(list(res[1].keys())), 0)
# to trigger 'Try again without dlocate if no packages found'
p = 'blablabla'
dlocate = True
res = utils.query_dpkg_for(p, dlocate)
- self.assertEquals(res[0], p)
- self.assertEquals(res[1], {})
+ self.assertEqual(res[0], p)
+ self.assertEqual(res[1], {})
-class TestMisc(unittest2.TestCase):
+class TestMisc(unittest.TestCase):
def test_first_run(self):
isfirstrun = utils.first_run()
self.assertIsNotNone(isfirstrun)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reportbug/reportbug.git
More information about the Reportbug-commits
mailing list