Back to index

moin  1.9.0~rc2
test_error.py
Go to the documentation of this file.
00001 # -*- coding: utf-8 -*-
00002 """
00003     MoinMoin - MoinMoin.error Tests
00004 
00005     @copyright: 2003-2004 by Nir Soffer <nirs AT freeshell DOT org>,
00006                 2007 by MoinMoin:ThomasWaldmann
00007     @license: GNU GPL, see COPYING for details.
00008 """
00009 
00010 import py
00011 
00012 from MoinMoin import error
00013 
00014 
00015 class TestEncoding(object):
00016     """ MoinMoin errors do work with unicode transparently """
00017 
00018     def testCreateWithUnicode(self):
00019         """ error: create with unicode """
00020         err = error.Error(u'טעות')
00021         assert unicode(err) == u'טעות'
00022         assert str(err) == 'טעות'
00023 
00024     def testCreateWithEncodedString(self):
00025         """ error: create with encoded string """
00026         err = error.Error('טעות')
00027         assert unicode(err) == u'טעות'
00028         assert str(err) == 'טעות'
00029 
00030     def testCreateWithObject(self):
00031         """ error: create with any object """
00032         class Foo:
00033             def __unicode__(self):
00034                 return u'טעות'
00035             def __str__(self):
00036                 return 'טעות'
00037 
00038         err = error.Error(Foo())
00039         assert unicode(err) == u'טעות'
00040         assert str(err) == 'טעות'
00041 
00042     def testAccessLikeDict(self):
00043         """ error: access error like a dict """
00044         test = 'value'
00045         err = error.Error(test)
00046         assert '%(message)s' % err == test
00047 
00048 coverage_modules = ['MoinMoin.error']
00049