From 5ca7bb365ebfcab7ef0d3f02023695a0133084c2 Mon Sep 17 00:00:00 2001 From: bendikro Date: Wed, 11 May 2016 18:24:40 +0200 Subject: [PATCH] [Tests] Use tests/common.todo_test to mark tests for TODO --- deluge/tests/common.py | 14 ++++++++++++++ deluge/tests/test_torrentmanager.py | 4 +++- deluge/tests/twisted/plugins/delugereporter.py | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/deluge/tests/common.py b/deluge/tests/common.py index 812a03b74..75bc1af24 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -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): diff --git a/deluge/tests/test_torrentmanager.py b/deluge/tests/test_torrentmanager.py index ed6adaa45..e8a8452e9 100644 --- a/deluge/tests/test_torrentmanager.py +++ b/deluge/tests/test_torrentmanager.py @@ -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") diff --git a/deluge/tests/twisted/plugins/delugereporter.py b/deluge/tests/twisted/plugins/delugereporter.py index 952fc7366..76433ef50 100644 --- a/deluge/tests/twisted/plugins/delugereporter.py +++ b/deluge/tests/twisted/plugins/delugereporter.py @@ -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