diff --git a/deluge/tests/common.py b/deluge/tests/common.py index 9f3fd1790..d751b85c6 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -75,9 +75,6 @@ def add_watchdog(deferred, timeout=0.05, message=None): return watchdog -def rpath(*args): - return os.path.join(os.path.dirname(__file__), *args) - # Initialize gettext lang.setup_translations() diff --git a/deluge/tests/deluge.png b/deluge/tests/data/deluge.png similarity index 100% rename from deluge/tests/deluge.png rename to deluge/tests/data/deluge.png diff --git a/deluge/tests/dir_with_6_files.torrent b/deluge/tests/data/dir_with_6_files.torrent similarity index 100% rename from deluge/tests/dir_with_6_files.torrent rename to deluge/tests/data/dir_with_6_files.torrent diff --git a/deluge/tests/google.ico b/deluge/tests/data/google.ico similarity index 100% rename from deluge/tests/google.ico rename to deluge/tests/data/google.ico diff --git a/deluge/tests/test.torrent b/deluge/tests/data/test.torrent similarity index 100% rename from deluge/tests/test.torrent rename to deluge/tests/data/test.torrent diff --git a/deluge/tests/test_torrent.file.torrent b/deluge/tests/data/test_torrent.file.torrent similarity index 100% rename from deluge/tests/test_torrent.file.torrent rename to deluge/tests/data/test_torrent.file.torrent diff --git a/deluge/tests/ubuntu-9.04-desktop-i386.iso.torrent b/deluge/tests/data/ubuntu-9.04-desktop-i386.iso.torrent similarity index 100% rename from deluge/tests/ubuntu-9.04-desktop-i386.iso.torrent rename to deluge/tests/data/ubuntu-9.04-desktop-i386.iso.torrent diff --git a/deluge/tests/ubuntu.png b/deluge/tests/data/ubuntu.png similarity index 100% rename from deluge/tests/ubuntu.png rename to deluge/tests/data/ubuntu.png diff --git a/deluge/tests/unicode_filenames.torrent b/deluge/tests/data/unicode_filenames.torrent similarity index 100% rename from deluge/tests/unicode_filenames.torrent rename to deluge/tests/data/unicode_filenames.torrent diff --git a/deluge/tests/openbt.png b/deluge/tests/openbt.png deleted file mode 100644 index 270d617ae..000000000 Binary files a/deluge/tests/openbt.png and /dev/null differ diff --git a/deluge/tests/publicbt.ico b/deluge/tests/publicbt.ico deleted file mode 100644 index 54b10a810..000000000 Binary files a/deluge/tests/publicbt.ico and /dev/null differ diff --git a/deluge/tests/test_core.py b/deluge/tests/test_core.py index c2d47022e..6d9165dac 100644 --- a/deluge/tests/test_core.py +++ b/deluge/tests/test_core.py @@ -33,7 +33,7 @@ class CookieResource(Resource): return request.setHeader("Content-Type", "application/x-bittorrent") - with open(common.rpath("ubuntu-9.04-desktop-i386.iso.torrent")) as _file: + with open(common.get_test_data_file("ubuntu-9.04-desktop-i386.iso.torrent")) as _file: data = _file.read() return data @@ -41,7 +41,7 @@ class CookieResource(Resource): class PartialDownload(Resource): def render(self, request): - with open(common.rpath("ubuntu-9.04-desktop-i386.iso.torrent")) as _file: + with open(common.get_test_data_file("ubuntu-9.04-desktop-i386.iso.torrent")) as _file: data = _file.read() request.setHeader("Content-Type", len(data)) request.setHeader("Content-Type", "application/x-bittorrent") @@ -67,7 +67,7 @@ class TopLevelResource(Resource): self.putChild("partial", PartialDownload()) self.putChild("redirect", RedirectResource()) self.putChild("ubuntu-9.04-desktop-i386.iso.torrent", - File(common.rpath("ubuntu-9.04-desktop-i386.iso.torrent"))) + File(common.get_test_data_file("ubuntu-9.04-desktop-i386.iso.torrent"))) class CoreTestCase(BaseTestCase): @@ -109,7 +109,7 @@ class CoreTestCase(BaseTestCase): filenames = ["test.torrent", "test_torrent.file.torrent"] files_to_add = [] for f in filenames: - filename = common.rpath(f) + filename = common.get_test_data_file(f) with open(filename) as _file: filedump = base64.encodestring(_file.read()) files_to_add.append((filename, filedump, options)) @@ -122,7 +122,7 @@ class CoreTestCase(BaseTestCase): filenames = ["test.torrent", "test.torrent"] files_to_add = [] for f in filenames: - filename = common.rpath(f) + filename = common.get_test_data_file(f) with open(filename) as _file: filedump = base64.encodestring(_file.read()) files_to_add.append((filename, filedump, options)) @@ -133,7 +133,7 @@ class CoreTestCase(BaseTestCase): @defer.inlineCallbacks def test_add_torrent_file(self): options = {} - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) @@ -146,7 +146,7 @@ class CoreTestCase(BaseTestCase): def test_add_torrent_file_invalid_filedump(self): options = {} - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") self.assertRaises(AddTorrentError, self.core.add_torrent_file, filename, False, options) @defer.inlineCallbacks @@ -201,7 +201,7 @@ class CoreTestCase(BaseTestCase): @defer.inlineCallbacks def test_remove_torrent(self): options = {} - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) @@ -215,12 +215,12 @@ class CoreTestCase(BaseTestCase): @defer.inlineCallbacks def test_remove_torrents(self): options = {} - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) - filename2 = common.rpath("unicode_filenames.torrent") + filename2 = common.get_test_data_file("unicode_filenames.torrent") with open(filename2) as _file: filedump = base64.encodestring(_file.read()) torrent_id2 = yield self.core.add_torrent_file(filename2, filedump, options) @@ -238,7 +238,7 @@ class CoreTestCase(BaseTestCase): @defer.inlineCallbacks def test_remove_torrents_invalid(self): options = {} - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) diff --git a/deluge/tests/test_torrent.py b/deluge/tests/test_torrent.py index 572e1afa5..7d864c067 100644 --- a/deluge/tests/test_torrent.py +++ b/deluge/tests/test_torrent.py @@ -52,7 +52,7 @@ class TorrentTestCase(BaseTestCase): self.assertEquals(torrent.state, state) def get_torrent_atp(self, filename): - filename = common.rpath(filename) + filename = common.get_test_data_file(filename) with open(filename, 'rb') as _file: info = lt.torrent_info(lt.bdecode(_file.read())) atp = {"ti": info} @@ -117,7 +117,7 @@ class TorrentTestCase(BaseTestCase): @defer.inlineCallbacks def test_torrent_error_data_missing(self): options = {"seed_mode": True} - filename = common.rpath("test_torrent.file.torrent") + filename = common.get_test_data_file("test_torrent.file.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) @@ -133,7 +133,7 @@ class TorrentTestCase(BaseTestCase): @defer.inlineCallbacks def test_torrent_error_resume_original_state(self): options = {"seed_mode": True, "add_paused": True} - filename = common.rpath("test_torrent.file.torrent") + filename = common.get_test_data_file("test_torrent.file.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, options) @@ -178,7 +178,7 @@ class TorrentTestCase(BaseTestCase): is_finished=True, ) - filename = common.rpath("test_torrent.file.torrent") + filename = common.get_test_data_file("test_torrent.file.torrent") with open(filename) as _file: filedump = _file.read() torrent_id = yield self.core.torrentmanager.add(state=torrent_state, filedump=filedump, diff --git a/deluge/tests/test_torrentmanager.py b/deluge/tests/test_torrentmanager.py index cabd0bb57..b1c90fdbd 100644 --- a/deluge/tests/test_torrentmanager.py +++ b/deluge/tests/test_torrentmanager.py @@ -29,7 +29,7 @@ class TorrentmanagerTestCase(BaseTestCase): @defer.inlineCallbacks def test_remove_torrent(self): - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") with open(filename) as _file: filedump = base64.encodestring(_file.read()) torrent_id = yield self.core.add_torrent_file(filename, filedump, {}) diff --git a/deluge/tests/test_tracker_icons.py b/deluge/tests/test_tracker_icons.py index aeebd64df..ac76a1dcb 100644 --- a/deluge/tests/test_tracker_icons.py +++ b/deluge/tests/test_tracker_icons.py @@ -1,5 +1,3 @@ -import os - import pytest import deluge.component as component @@ -10,7 +8,6 @@ from . import common from .basetest import BaseTestCase common.set_tmp_config_dir() -dirname = os.path.dirname(__file__) deluge.ui.tracker_icons.PIL_INSTALLED = False common.disable_new_release_check() @@ -26,7 +23,7 @@ class TrackerIconsTestCase(BaseTestCase): def test_get_deluge_png(self): # Deluge has a png favicon link - icon = TrackerIcon(os.path.join(dirname, "deluge.png")) + icon = TrackerIcon(common.get_test_data_file("deluge.png")) d = self.icons.fetch("deluge-torrent.org") d.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) @@ -35,7 +32,7 @@ class TrackerIconsTestCase(BaseTestCase): def test_get_google_ico(self): # Google doesn't have any icon links # So instead we'll grab its favicon.ico - icon = TrackerIcon(os.path.join(dirname, "google.ico")) + icon = TrackerIcon(common.get_test_data_file("google.ico")) d = self.icons.fetch("www.google.com") d.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) @@ -43,7 +40,7 @@ class TrackerIconsTestCase(BaseTestCase): def test_get_google_ico_with_redirect(self): # google.com redirects to www.google.com - icon = TrackerIcon(os.path.join(dirname, "google.ico")) + icon = TrackerIcon(common.get_test_data_file("google.ico")) d = self.icons.fetch("google.com") d.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) @@ -51,7 +48,7 @@ class TrackerIconsTestCase(BaseTestCase): def test_get_ubuntu_ico(self): # ubuntu.com has inline css which causes HTMLParser issues - icon = TrackerIcon(os.path.join(dirname, "ubuntu.png")) + icon = TrackerIcon(common.get_test_data_file("ubuntu.png")) d = self.icons.fetch("www.ubuntu.com") d.addCallback(self.assertNotIdentical, None) d.addCallback(self.assertEquals, icon) diff --git a/deluge/tests/test_ui_common.py b/deluge/tests/test_ui_common.py index 55541e82b..a2c98c298 100644 --- a/deluge/tests/test_ui_common.py +++ b/deluge/tests/test_ui_common.py @@ -22,12 +22,12 @@ class UICommonTestCase(unittest.TestCase): pass def test_utf8_encoded_paths(self): - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") ti = TorrentInfo(filename) self.assertTrue("azcvsupdater_2.6.2.jar" in ti.files_tree) def test_utf8_encoded_paths2(self): - filename = common.rpath("unicode_filenames.torrent") + filename = common.get_test_data_file("unicode_filenames.torrent") ti = TorrentInfo(filename) files = ti.files_tree["unicode_filenames"] diff --git a/deluge/tests/test_web_api.py b/deluge/tests/test_web_api.py index a2cc54bd0..dfcbce77f 100644 --- a/deluge/tests/test_web_api.py +++ b/deluge/tests/test_web_api.py @@ -121,7 +121,7 @@ class WebAPITestCase(WebServerTestBase): self.assertFalse(self.deluge_web.web_api.remove_host(conn[0])) def test_get_torrent_info(self): - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") ret = self.deluge_web.web_api.get_torrent_info(filename) self.assertEquals(ret["name"], "azcvsupdater_2.6.2.jar") self.assertEquals(ret["info_hash"], "ab570cdd5a17ea1b61e970bb72047de141bce173") @@ -136,7 +136,7 @@ class WebAPITestCase(WebServerTestBase): @defer.inlineCallbacks def test_get_torrent_files(self): yield self.deluge_web.web_api.connect(self.host_id) - filename = common.rpath("test.torrent") + filename = common.get_test_data_file("test.torrent") torrents = [{"path": filename, "options": {"download_location": "/home/deluge/"}}] yield self.deluge_web.web_api.add_torrents(torrents) ret = yield self.deluge_web.web_api.get_torrent_files("ab570cdd5a17ea1b61e970bb72047de141bce173") @@ -148,7 +148,7 @@ class WebAPITestCase(WebServerTestBase): @defer.inlineCallbacks def test_download_torrent_from_url(self): filename = "ubuntu-9.04-desktop-i386.iso.torrent" - self.deluge_web.top_level.putChild(filename, File(common.rpath(filename))) + self.deluge_web.top_level.putChild(filename, File(common.get_test_data_file(filename))) url = "http://localhost:%d/%s" % (self.webserver_listen_port, filename) res = yield self.deluge_web.web_api.download_torrent_from_url(url) self.assertTrue(res.endswith(filename))