From 1fa2de066fe6cd25954e2497b021944ef452d2f5 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Wed, 27 Jun 2018 14:18:49 +0100 Subject: [PATCH] Fix mistakes in test code --- deluge/tests/common.py | 13 +++++++------ deluge/tests/daemon_base.py | 2 +- deluge/tests/test_bencode.py | 4 ++-- deluge/tests/test_client.py | 2 +- deluge/tests/test_core.py | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/deluge/tests/common.py b/deluge/tests/common.py index 79d4052f6..877b67654 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -240,19 +240,20 @@ import deluge.core.daemon_entry from deluge.common import windows_check - if windows_check(): - sys.argv.extend(['-c', '%s', '-L', 'info', '-p', '%d']) - else - sys.argv.extend(['-d', '-c', '%s', '-L', 'info', '-p', '%d']) +if windows_check(): + sys.argv.extend(['-c', '%(dir)s', '-L', 'info', '-p', '%(port)d']) +else: + sys.argv.extend(['-d', '-c', '%(dir)s', '-L', 'info', '-p', '%(port)d']) try: daemon = deluge.core.daemon_entry.start_daemon(skip_start=True) - %s + %(script)s daemon.start() except Exception: import traceback 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 = [] default_core_cb = {'deferred': Deferred(), 'types': 'stdout'} if timeout: diff --git a/deluge/tests/daemon_base.py b/deluge/tests/daemon_base.py index 24af09848..9cd286ba3 100644 --- a/deluge/tests/daemon_base.py +++ b/deluge/tests/daemon_base.py @@ -21,7 +21,7 @@ from . import common class DaemonBase(object): - if windows_check: + if windows_check(): skip = 'windows cant start_core not enough arguments for format string' def common_set_up(self): diff --git a/deluge/tests/test_bencode.py b/deluge/tests/test_bencode.py index 4d0de3546..760a691af 100644 --- a/deluge/tests/test_bencode.py +++ b/deluge/tests/test_bencode.py @@ -18,8 +18,8 @@ class BencodeTestCase(unittest.TestCase): def test_bencode_unicode_metainfo(self): filename = common.get_test_data_file('test.torrent') with open(filename, 'rb') as _file: - metainfo = bencode.bdecode(_file.read())['info'] + metainfo = bencode.bdecode(_file.read())[b'info'] bencode.bencode({b'info': metainfo}) def test_bencode_unicode_value(self): - self.assertEqual(bencode.bencode('abc'), '3:abc') + self.assertEqual(bencode.bencode('abc'), b'3:abc') diff --git a/deluge/tests/test_client.py b/deluge/tests/test_client.py index 7a8a35bc9..9a237f261 100644 --- a/deluge/tests/test_client.py +++ b/deluge/tests/test_client.py @@ -77,7 +77,7 @@ class NoVersionSendingClient(Client): class ClientTestCase(BaseTestCase, DaemonBase): - if windows_check: + if windows_check(): skip = 'windows cant start_core not enough arguments for format string' def set_up(self): diff --git a/deluge/tests/test_core.py b/deluge/tests/test_core.py index 44ed8e51e..c77253c98 100644 --- a/deluge/tests/test_core.py +++ b/deluge/tests/test_core.py @@ -153,7 +153,7 @@ class CoreTestCase(BaseTestCase): # Get the info hash from the test.torrent from deluge.bencode import bdecode, bencode 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) def test_add_torrent_file_invalid_filedump(self):