[Tests] Use tests/common.todo_test to mark tests for TODO

This commit is contained in:
bendikro 2016-05-11 18:24:40 +02:00
parent 260268f62b
commit 5ca7bb365e
3 changed files with 19 additions and 1 deletions

View File

@ -1,10 +1,12 @@
import os
import sys
import tempfile
import traceback
from twisted.internet import defer, protocol, reactor
from twisted.internet.defer import Deferred
from twisted.internet.error import CannotListenError
from twisted.trial import unittest
import deluge.configmanager
import deluge.core.preferencesmanager
@ -25,6 +27,18 @@ def set_tmp_config_dir():
return config_directory
def todo_test(caller):
# If we are using the delugereporter we can set todo mark on the test
# Without the delugereporter the todo would print a stack trace, so in
# that case we rely only on skipTest
if os.environ.get("DELUGE_REPORTER", None):
getattr(caller, caller._testMethodName).im_func.todo = "To be fixed"
filename = os.path.basename(traceback.extract_stack(None, 2)[0][0])
funcname = traceback.extract_stack(None, 2)[0][2]
raise unittest.SkipTest("TODO: %s:%s" % (filename, funcname))
def add_watchdog(deferred, timeout=0.05, message=None):
def callback(value):

View File

@ -2,6 +2,7 @@ import base64
import os
import warnings
import pytest
from twisted.internet import defer
from deluge import component
@ -33,9 +34,10 @@ class TorrentmanagerTestCase(BaseTestCase):
torrent_id = yield self.core.add_torrent_file(filename, base64.encodestring(open(filename).read()), {})
self.assertTrue(self.core.torrentmanager.remove(torrent_id, False))
@pytest.mark.todo
def test_remove_torrent_false(self):
"""Test when remove_torrent returns False"""
raise unittest.SkipTest("")
common.todo_test(self)
def test_remove_invalid_torrent(self):
self.assertRaises(InvalidTorrentError, self.core.torrentmanager.remove, "torrentidthatdoesntexist")

View File

@ -1,4 +1,5 @@
#! /usr/bin/env python
import os
from twisted.plugin import IPlugin
from twisted.trial.itrial import IReporter
@ -28,6 +29,7 @@ deluge = _Reporter("Deluge reporter that suppresses Stacktrace from TODO tests",
class DelugeReporter(TreeReporter):
def __init__(self, *args, **kwargs):
os.environ["DELUGE_REPORTER"] = "true"
TreeReporter.__init__(self, *args, **kwargs)
def addExpectedFailure(self, *args): # NOQA