annotate Lib/test/testcodec.py @ 58765:2ba7677bfa95 legacy-trunk

testCopysign was defined twice in test_math; combine the definitions
author Mark Dickinson <dickinsm@gmail.com>
date Sat, 06 Feb 2010 23:11:25 +0000
parents f16545f58345
children beacf40b5960
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15795
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
1 """ Test Codecs (used by test_charmapcodec)
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
2
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
3 Written by Marc-Andre Lemburg (mal@lemburg.com).
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
4
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
5 (c) Copyright 2000 Guido van Rossum.
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
6
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
7 """#"
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
8 import codecs
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
9
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
10 ### Codec APIs
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
11
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
12 class Codec(codecs.Codec):
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
13
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
14 def encode(self,input,errors='strict'):
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
15
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
16 return codecs.charmap_encode(input,errors,encoding_map)
15977
f16545f58345 Whitespace normalization. Leaving tokenize_tests.py alone for now.
Tim Peters <tim.peters@gmail.com>
parents: 15795
diff changeset
17
15795
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
18 def decode(self,input,errors='strict'):
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
19
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
20 return codecs.charmap_decode(input,errors,decoding_map)
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
21
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
22 class StreamWriter(Codec,codecs.StreamWriter):
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
23 pass
15977
f16545f58345 Whitespace normalization. Leaving tokenize_tests.py alone for now.
Tim Peters <tim.peters@gmail.com>
parents: 15795
diff changeset
24
15795
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
25 class StreamReader(Codec,codecs.StreamReader):
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
26 pass
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
27
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
28 ### encodings module API
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
29
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
30 def getregentry():
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
31
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
32 return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
33
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
34 ### Decoding Map
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
35
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
36 decoding_map = codecs.make_identity_dict(range(256))
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
37 decoding_map.update({
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
38 0x78: u"abc", # 1-n decoding mapping
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
39 "abc": 0x0078,# 1-n encoding mapping
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
40 0x01: None, # decoding mapping to <undefined>
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
41 0x79: u"", # decoding mapping to <remove character>
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
42 })
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
43
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
44 ### Encoding Map
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
45
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
46 encoding_map = {}
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
47 for k,v in decoding_map.items():
63c0483eff68 Moved the test codec definition to a new module and updated the test and
Marc-André Lemburg <mal@egenix.com>
parents:
diff changeset
48 encoding_map[v] = k