view MoinMoin/util/_tests/ @ 2657:080673c3e60a

Now nameless items can also be downloaded and removed unnecessary blank spaces in items/
author Saurabh Kathpalia <>
date Sun, 06 Jul 2014 09:25:31 +0530
parents 181a556a0920
line wrap: on
line source
# -*- coding: utf-8 -*-
# Copyright: 2011 Prashant Kumar <contactprashantat AT gmail DOT com>
# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.

MoinMoin - MoinMoin.util.thread_monitor Tests

import shutil
import tempfile
import os

from MoinMoin.util.thread_monitor import Monitor

class TestMonitor(object):
    """ Tests: Monitor """

    def setup_method(self, method):
        self.test_dir = tempfile.mkdtemp('', 'test_dump')
        self.src = os.path.join(self.test_dir, "test_dumpfile")

    def teardown_method(self, method):

    def test_hook(self):
        """ tests for hooks """
        Monitor_test_obj = Monitor()
        result_inactivated = Monitor_test_obj.hook_enabled()
        assert not result_inactivated
        # activate the hook
        result_activated = Monitor_test_obj.hook_enabled()
        assert result_activated

    def test_trigger_dump(self):
        """ test for trigger_dump """
        Monitor_test_obj = Monitor()
        # activate the hook first
        with open(self.src, "w") as f:
            result = Monitor_test_obj.trigger_dump(f)
        # read the content of first line
        with open(self.src, "r") as f:
            assert 'Dumping thread' in f.readline()