~ubuntu-branches/ubuntu/karmic/python-docutils/karmic

« back to all changes in this revision

Viewing changes to test/test_transforms/test___init__.py

  • Committer: Bazaar Package Importer
  • Author(s): martin f. krafft
  • Date: 2006-07-10 11:45:05 UTC
  • mfrom: (2.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060710114505-otkhqcslevewxmz5
Tags: 0.4-3
Added build dependency on python-central (closes: #377580).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
 
 
3
# Author: Felix Wiemann
 
4
# Contact: Felix_Wiemann@ososo.de
 
5
# Revision: $Revision: 4132 $
 
6
# Date: $Date: 2005-12-03 03:13:12 +0100 (Sat, 03 Dec 2005) $
 
7
# Copyright: This module has been placed in the public domain.
 
8
 
 
9
"""
 
10
Test module for transforms/__init__.py.
 
11
"""
 
12
 
 
13
from __init__ import DocutilsTestSupport # must be imported before docutils
 
14
from docutils import transforms, utils
 
15
import unittest
 
16
 
 
17
 
 
18
class TestTransform(transforms.Transform):
 
19
 
 
20
    default_priority = 100
 
21
 
 
22
    applied = 0
 
23
    
 
24
    def apply(self, **kwargs):
 
25
        self.applied += 1
 
26
        assert kwargs == {'foo': 42}
 
27
 
 
28
 
 
29
class KwargsTestCase(unittest.TestCase):
 
30
 
 
31
    def test_kwargs(self):
 
32
        transformer = transforms.Transformer(utils.new_document('test data'))
 
33
        transformer.add_transform(TestTransform, foo=42)
 
34
        transformer.apply_transforms()
 
35
        self.assertEqual(len(transformer.applied), 1)
 
36
        self.assertEqual(len(transformer.applied[0]), 4)
 
37
        transform_record = transformer.applied[0]
 
38
        self.assertEqual(transform_record[1], TestTransform)
 
39
        self.assertEqual(transform_record[3], {'foo': 42})
 
40
 
 
41
 
 
42
if __name__ == '__main__':
 
43
    unittest.main()