diff --git a/Tribler/Test/API/test_seeding_vod.py b/Tribler/Test/API/test_seeding_vod.py index 6fe358165b6..b669a85024e 100644 --- a/Tribler/Test/API/test_seeding_vod.py +++ b/Tribler/Test/API/test_seeding_vod.py @@ -1,9 +1,7 @@ # Written by Arno Bakker, heavily modified by Niels Zeilemaker # see LICENSE.txt for license information -import sys -import threading -from twisted.internet.defer import inlineCallbacks +from twisted.internet.defer import inlineCallbacks, Deferred from Tribler.Test.API.test_seeding import TestSeeding from Tribler.Core.simpledefs import dlstatus_strings, DLMODE_VOD @@ -17,16 +15,17 @@ class TestVODSeeding(TestSeeding): def setUp(self): super(TestVODSeeding, self).setUp() - self.vod_event = threading.Event() + self.vod_deferred = Deferred() + @inlineCallbacks def setup_seeder(self, filename='video.avi'): - super(TestVODSeeding, self).setup_seeder(filename) + yield super(TestVODSeeding, self).setup_seeder(filename) @inlineCallbacks def subtest_download(self): self.dscfg2.set_mode(DLMODE_VOD) yield super(TestVODSeeding, self).subtest_download() - assert self.vod_event.wait(60) + yield self.vod_deferred def downloader_state_callback(self, ds): d = ds.get_download() @@ -35,8 +34,10 @@ def downloader_state_callback(self, ds): ds.get_vod_prebuffering_progress()) if ds.get_progress() > 0: - self.downloading_event.set() + if not self.downloading_deferred.called: + self.downloading_deferred.callback(None) if ds.get_vod_prebuffering_progress() == 1.0: - self.vod_event.set() + if not self.vod_deferred.called: + self.vod_deferred.callback(None) return 1.0, False diff --git a/Tribler/Test/Core/CreditMining/test_creditmining_sys.py b/Tribler/Test/Core/CreditMining/test_creditmining_sys.py index e1c1b4f87cb..9ef44692f78 100644 --- a/Tribler/Test/Core/CreditMining/test_creditmining_sys.py +++ b/Tribler/Test/Core/CreditMining/test_creditmining_sys.py @@ -14,9 +14,10 @@ from twisted.web.server import Site from twisted.web.static import File +from nose.twistedtools import reactor, deferred + from Tribler.Core.DownloadConfig import DefaultDownloadStartupConfig from Tribler.Core.TorrentDef import TorrentDef -from Tribler.Core.Utilities.twisted_thread import deferred, reactor from Tribler.Core.simpledefs import NTFY_TORRENTS, NTFY_UPDATE, NTFY_CHANNELCAST from Tribler.Main.Utility.GuiDBTuples import CollectedTorrent from Tribler.Policies.BoostingManager import BoostingManager, BoostingSettings diff --git a/Tribler/Test/Core/Modules/RestApi/Channels/test_channels_endpoint.py b/Tribler/Test/Core/Modules/RestApi/Channels/test_channels_endpoint.py index 190eabd0495..5bb18db32ae 100644 --- a/Tribler/Test/Core/Modules/RestApi/Channels/test_channels_endpoint.py +++ b/Tribler/Test/Core/Modules/RestApi/Channels/test_channels_endpoint.py @@ -1,8 +1,10 @@ import json + +from nose.twistedtools import deferred + from Tribler.Core.Modules.channel.channel import ChannelObject from Tribler.Core.Modules.channel.channel_manager import ChannelManager -from Tribler.Core.Utilities.twisted_thread import deferred from Tribler.Core.exceptions import DuplicateChannelNameError from Tribler.Core.simpledefs import NTFY_CHANNELCAST, NTFY_VOTECAST from Tribler.Test.Core.Modules.RestApi.base_api_test import AbstractApiTest diff --git a/Tribler/Test/Core/Modules/RestApi/Channels/test_create_channel_endpoint.py b/Tribler/Test/Core/Modules/RestApi/Channels/test_create_channel_endpoint.py index d8c9bb18f6c..f1671bb32bd 100644 --- a/Tribler/Test/Core/Modules/RestApi/Channels/test_create_channel_endpoint.py +++ b/Tribler/Test/Core/Modules/RestApi/Channels/test_create_channel_endpoint.py @@ -1,5 +1,7 @@ import json -from Tribler.Core.Utilities.twisted_thread import deferred + +from nose.twistedtools import deferred + from Tribler.Test.Core.Modules.RestApi.Channels.test_channels_endpoint import AbstractTestChannelsEndpoint diff --git a/Tribler/Test/Core/test_network_utils.py b/Tribler/Test/Core/test_network_utils.py index 239b532a153..09c0107fff7 100644 --- a/Tribler/Test/Core/test_network_utils.py +++ b/Tribler/Test/Core/test_network_utils.py @@ -1,9 +1,10 @@ import socket -from Tribler.Core.Utilities.twisted_thread import reactor, deferred from nose.tools import raises from twisted.internet.protocol import Factory +from nose.twistedtools import deferred, reactor + from Tribler.Core.Utilities.network_utils import get_random_port, autodetect_socket_style, InterruptSocket from Tribler.Test.Core.base_test import TriblerCoreTest diff --git a/Tribler/Test/Core/test_threadpoolmanager.py b/Tribler/Test/Core/test_threadpoolmanager.py index a09aa69db85..0b4485dbacf 100644 --- a/Tribler/Test/Core/test_threadpoolmanager.py +++ b/Tribler/Test/Core/test_threadpoolmanager.py @@ -1,7 +1,8 @@ from twisted.internet.defer import Deferred +from nose.twistedtools import deferred + from Tribler.Core.APIImplementation.threadpoolmanager import ThreadPoolManager -from Tribler.Core.Utilities.twisted_thread import deferred from Tribler.Test.Core.base_test import TriblerCoreTest diff --git a/Tribler/Test/Core/test_torrentchecker_session.py b/Tribler/Test/Core/test_torrentchecker_session.py index fdce5222568..ce27ac5094f 100644 --- a/Tribler/Test/Core/test_torrentchecker_session.py +++ b/Tribler/Test/Core/test_torrentchecker_session.py @@ -5,8 +5,9 @@ from twisted.internet.defer import Deferred, DeferredList, inlineCallbacks +from nose.twistedtools import deferred, reactor + from Tribler.Core.TorrentChecker.session import HttpTrackerSession, UDPScraper, UdpTrackerSession -from Tribler.Core.Utilities.twisted_thread import deferred, reactor from Tribler.Test.Core.base_test import TriblerCoreTest