Staging
v0.5.1
v0.5.1
https://foss.heptapod.net/mercurial/hgview
Tip revision: 0fdcc033b9b3b62cd94fbbe463670786f500da8e authored by Alain Leufroy on 29 September 2011, 10:54:33 UTC
Added tag hgview-version-1.4.0 for changeset 1576aa8d7b12
Added tag hgview-version-1.4.0 for changeset 1576aa8d7b12
Tip revision: 0fdcc03
tests_application_patches.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2003-2011 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from doctest import testmod
from unittest import main, TestCase
import logging
import urwid
from hgviewlib.curses.application import *
class TestConnectLogging(TestCase):
def setUp(self):
from urwid import Text, Filler, Text, raw_display, MainLoop
from hgviewlib.curses.application import connect_logging
from hgviewlib.curses import MainFrame, Body
import logging
PALETTE = [('default','default','default'),
('edit', 'white', 'default'),
('banner','black','light gray'),
('DEBUG', 'yellow', 'default'),
('INFO', 'dark gray', 'default'),
('WARNING', 'brown', 'default'),
('ERROR', 'light red', 'default'),
('CRITICAL', 'white', 'dark red'),
]
self.mainframe = MainFrame('', Body(Filler(Text('Hello world'))))
screen = raw_display.Screen()
mainloop = MainLoop(self.mainframe, PALETTE, screen)
connect_logging(mainloop, logging.DEBUG)
def test_simple_info(self):
logging.info('noo')
res = self.mainframe.render((15, 2), False).text
self.assertEqual('noo', self.mainframe.footer.get_text()[0])
self.assertEqual('INFO', self.mainframe.footer.attr)
def test_display_traceback(self):
try:
1/0
except:
logging.debug('hello world', exc_info=True)
res = self.mainframe.footer.get_text()[0].splitlines()
ref = ['hello world', 'Traceback (most recent call last):']
self.assertEqual(ref, res[:2])