Fix mistakes in test code

This commit is contained in:
Calum Lind 2018-06-27 14:18:49 +01:00
parent ae0b070c1b
commit 1fa2de066f
5 changed files with 12 additions and 11 deletions

View File

@ -240,19 +240,20 @@ import deluge.core.daemon_entry
from deluge.common import windows_check from deluge.common import windows_check
if windows_check(): if windows_check():
sys.argv.extend(['-c', '%s', '-L', 'info', '-p', '%d']) sys.argv.extend(['-c', '%(dir)s', '-L', 'info', '-p', '%(port)d'])
else else:
sys.argv.extend(['-d', '-c', '%s', '-L', 'info', '-p', '%d']) sys.argv.extend(['-d', '-c', '%(dir)s', '-L', 'info', '-p', '%(port)d'])
try: try:
daemon = deluge.core.daemon_entry.start_daemon(skip_start=True) daemon = deluge.core.daemon_entry.start_daemon(skip_start=True)
%s %(script)s
daemon.start() daemon.start()
except Exception: except Exception:
import traceback import traceback
sys.stderr.write('Exception raised:\\n %%s' %% traceback.format_exc()) sys.stderr.write('Exception raised:\\n %%s' %% traceback.format_exc())
""" % (config_directory, listen_port, custom_script) """ % {'dir': config_directory, 'port': listen_port, 'script': custom_script}
callbacks = [] callbacks = []
default_core_cb = {'deferred': Deferred(), 'types': 'stdout'} default_core_cb = {'deferred': Deferred(), 'types': 'stdout'}
if timeout: if timeout:

View File

@ -21,7 +21,7 @@ from . import common
class DaemonBase(object): class DaemonBase(object):
if windows_check: if windows_check():
skip = 'windows cant start_core not enough arguments for format string' skip = 'windows cant start_core not enough arguments for format string'
def common_set_up(self): def common_set_up(self):

View File

@ -18,8 +18,8 @@ class BencodeTestCase(unittest.TestCase):
def test_bencode_unicode_metainfo(self): def test_bencode_unicode_metainfo(self):
filename = common.get_test_data_file('test.torrent') filename = common.get_test_data_file('test.torrent')
with open(filename, 'rb') as _file: with open(filename, 'rb') as _file:
metainfo = bencode.bdecode(_file.read())['info'] metainfo = bencode.bdecode(_file.read())[b'info']
bencode.bencode({b'info': metainfo}) bencode.bencode({b'info': metainfo})
def test_bencode_unicode_value(self): def test_bencode_unicode_value(self):
self.assertEqual(bencode.bencode('abc'), '3:abc') self.assertEqual(bencode.bencode('abc'), b'3:abc')

View File

@ -77,7 +77,7 @@ class NoVersionSendingClient(Client):
class ClientTestCase(BaseTestCase, DaemonBase): class ClientTestCase(BaseTestCase, DaemonBase):
if windows_check: if windows_check():
skip = 'windows cant start_core not enough arguments for format string' skip = 'windows cant start_core not enough arguments for format string'
def set_up(self): def set_up(self):

View File

@ -153,7 +153,7 @@ class CoreTestCase(BaseTestCase):
# Get the info hash from the test.torrent # Get the info hash from the test.torrent
from deluge.bencode import bdecode, bencode from deluge.bencode import bdecode, bencode
with open(filename, 'rb') as _file: with open(filename, 'rb') as _file:
info_hash = sha(bencode(bdecode(_file.read())['info'])).hexdigest() info_hash = sha(bencode(bdecode(_file.read())[b'info'])).hexdigest()
self.assertEqual(torrent_id, info_hash) self.assertEqual(torrent_id, info_hash)
def test_add_torrent_file_invalid_filedump(self): def test_add_torrent_file_invalid_filedump(self):