Skip to content

Commit

Permalink
Replaced our deferred and reactor with nose's for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lfdversluis committed Jul 30, 2016
1 parent 5134adc commit 596cb4a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
17 changes: 9 additions & 8 deletions Tribler/Test/API/test_seeding_vod.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
Expand All @@ -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
3 changes: 2 additions & 1 deletion Tribler/Test/Core/CreditMining/test_creditmining_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion Tribler/Test/Core/test_network_utils.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 2 additions & 1 deletion Tribler/Test/Core/test_threadpoolmanager.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
3 changes: 2 additions & 1 deletion Tribler/Test/Core/test_torrentchecker_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 596cb4a

Please sign in to comment.