Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_logging.FormatterTest Class Reference

List of all members.

Public Member Functions

def setUp
def get_record
def test_percent
def test_braces
def test_dollars

Public Attributes

 common
 variants

Detailed Description

Definition at line 2113 of file test_logging.py.


Member Function Documentation

def test.test_logging.FormatterTest.get_record (   self,
  name = None 
)

Definition at line 2128 of file test_logging.py.

02128 
02129     def get_record(self, name=None):
02130         result = dict(self.common)
02131         if name is not None:
02132             result.update(self.variants[name])
02133         return logging.makeLogRecord(result)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2114 of file test_logging.py.

02114 
02115     def setUp(self):
02116         self.common = {
02117             'name': 'formatter.test',
02118             'level': logging.DEBUG,
02119             'pathname': os.path.join('path', 'to', 'dummy.ext'),
02120             'lineno': 42,
02121             'exc_info': None,
02122             'func': None,
02123             'msg': 'Message with %d %s',
02124             'args': (2, 'placeholders'),
02125         }
02126         self.variants = {
02127         }

Here is the caller graph for this function:

Definition at line 2149 of file test_logging.py.

02149 
02150     def test_braces(self):
02151         # Test {}-formatting
02152         r = self.get_record()
02153         f = logging.Formatter('$%{message}%$', style='{')
02154         self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
02155         f = logging.Formatter('{random}', style='{')
02156         self.assertRaises(KeyError, f.format, r)
02157         self.assertFalse(f.usesTime())
02158         f = logging.Formatter('{asctime}', style='{')
02159         self.assertTrue(f.usesTime())
02160         f = logging.Formatter('{asctime!s:15}', style='{')
02161         self.assertTrue(f.usesTime())
02162         f = logging.Formatter('{asctime:15}', style='{')
02163         self.assertTrue(f.usesTime())
02164         f = logging.Formatter('asctime', style='{')
02165         self.assertFalse(f.usesTime())

Here is the call graph for this function:

Definition at line 2166 of file test_logging.py.

02166 
02167     def test_dollars(self):
02168         # Test $-formatting
02169         r = self.get_record()
02170         f = logging.Formatter('$message', style='$')
02171         self.assertEqual(f.format(r), 'Message with 2 placeholders')
02172         f = logging.Formatter('$$%${message}%$$', style='$')
02173         self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
02174         f = logging.Formatter('${random}', style='$')
02175         self.assertRaises(KeyError, f.format, r)
02176         self.assertFalse(f.usesTime())
02177         f = logging.Formatter('${asctime}', style='$')
02178         self.assertTrue(f.usesTime())
02179         f = logging.Formatter('${asctime', style='$')
02180         self.assertFalse(f.usesTime())
02181         f = logging.Formatter('$asctime', style='$')
02182         self.assertTrue(f.usesTime())
02183         f = logging.Formatter('asctime', style='$')
02184         self.assertFalse(f.usesTime())

Here is the call graph for this function:

Definition at line 2134 of file test_logging.py.

02134 
02135     def test_percent(self):
02136         # Test %-formatting
02137         r = self.get_record()
02138         f = logging.Formatter('${%(message)s}')
02139         self.assertEqual(f.format(r), '${Message with 2 placeholders}')
02140         f = logging.Formatter('%(random)s')
02141         self.assertRaises(KeyError, f.format, r)
02142         self.assertFalse(f.usesTime())
02143         f = logging.Formatter('%(asctime)s')
02144         self.assertTrue(f.usesTime())
02145         f = logging.Formatter('%(asctime)-15s')
02146         self.assertTrue(f.usesTime())
02147         f = logging.Formatter('asctime')
02148         self.assertFalse(f.usesTime())

Here is the call graph for this function:


Member Data Documentation

Definition at line 2115 of file test_logging.py.

Definition at line 2125 of file test_logging.py.


The documentation for this class was generated from the following file: