summaryrefslogtreecommitdiffstats
path: root/deluge/tests/test_log.py
blob: 572693b7c454649bb089cc927785ab2fc4d44dc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 Calum Lind <calumlind@gmail.com>
# Copyright (C) 2010 Pedro Algarvio <ufs@ufsoft.org>
#
# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
# the additional special exception to link portions of this program with the OpenSSL library.
# See LICENSE for more details.
#

from __future__ import unicode_literals

import logging
import warnings

from deluge.log import setup_logger

from .basetest import BaseTestCase


class LogTestCase(BaseTestCase):
    def set_up(self):
        setup_logger(logging.DEBUG)

    def tear_down(self):
        setup_logger('none')

    def test_old_log_deprecation_warning(self):
        from deluge.log import LOG

        with warnings.catch_warnings(record=True) as w:
            # Cause all warnings to always be triggered.
            warnings.simplefilter('always')
            LOG.debug('foo')
            self.assertEqual(w[-1].category, DeprecationWarning)

    # def test_twisted_error_log(self):
    #    from twisted.internet import defer
    #    import deluge.component as component
    #    from deluge.core.eventmanager import EventManager
    #    EventManager()
    #
    #    d = component.start()
    #
    #    @defer.inlineCallbacks
    #    def call(*args):
    #        yield component.pause(["EventManager"])
    #        yield component.start(["EventManager"])
    #
    #    d.addCallback(call)
    #    return d