Mercurial > babel > old > babel-test
annotate babel/tests/localedata.py @ 530:85e1beadacb0
Update the copyright line.
author | jruigrok |
---|---|
date | Sat, 05 Mar 2011 15:22:28 +0000 |
parents | 369300a7ebd3 |
children |
rev | line source |
---|---|
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
2 # |
530 | 3 # Copyright (C) 2007-2011 Edgewall Software |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
4 # All rights reserved. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
5 # |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
6 # This software is licensed as described in the file COPYING, which |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
7 # you should have received as part of this distribution. The terms |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
8 # are also available at http://babel.edgewall.org/wiki/License. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
9 # |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
10 # This software consists of voluntary contributions made by many |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
11 # individuals. For the exact contribution history, see the revision |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
12 # history and logs, available at http://babel.edgewall.org/log/. |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
13 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
14 import doctest |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
15 import unittest |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
16 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
17 from babel import localedata |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
18 |
375
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
19 |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
20 class MergeResolveTestCase(unittest.TestCase): |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
21 |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
22 def test_merge_items(self): |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
23 d = {1: 'foo', 3: 'baz'} |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
24 localedata.merge(d, {1: 'Foo', 2: 'Bar'}) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
25 self.assertEqual({1: 'Foo', 2: 'Bar', 3: 'baz'}, d) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
26 |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
27 def test_merge_nested_dict(self): |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
28 d1 = {'x': {'a': 1, 'b': 2, 'c': 3}} |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
29 d2 = {'x': {'a': 1, 'b': 12, 'd': 14}} |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
30 localedata.merge(d1, d2) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
31 self.assertEqual({ |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
32 'x': {'a': 1, 'b': 12, 'c': 3, 'd': 14} |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
33 }, d1) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
34 |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
35 def test_merge_nested_dict_no_overlap(self): |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
36 d1 = {'x': {'a': 1, 'b': 2}} |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
37 d2 = {'y': {'a': 11, 'b': 12}} |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
38 localedata.merge(d1, d2) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
39 self.assertEqual({ |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
40 'x': {'a': 1, 'b': 2}, |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
41 'y': {'a': 11, 'b': 12} |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
42 }, d1) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
43 |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
44 def test_merge_with_alias_and_resolve(self): |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
45 alias = localedata.Alias('x') |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
46 d1 = { |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
47 'x': {'a': 1, 'b': 2, 'c': 3}, |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
48 'y': alias |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
49 } |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
50 d2 = { |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
51 'x': {'a': 1, 'b': 12, 'd': 14}, |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
52 'y': {'b': 22, 'e': 25} |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
53 } |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
54 localedata.merge(d1, d2) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
55 self.assertEqual({ |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
56 'x': {'a': 1, 'b': 12, 'c': 3, 'd': 14}, |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
57 'y': (alias, {'b': 22, 'e': 25}) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
58 }, d1) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
59 d = localedata.LocaleDataDict(d1) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
60 self.assertEqual({ |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
61 'x': {'a': 1, 'b': 12, 'c': 3, 'd': 14}, |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
62 'y': {'a': 1, 'b': 22, 'c': 3, 'd': 14, 'e': 25} |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
63 }, dict(d.items())) |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
64 |
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
65 |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
66 def suite(): |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
67 suite = unittest.TestSuite() |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
68 suite.addTest(doctest.DocTestSuite(localedata)) |
375
369300a7ebd3
Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents:
26
diff
changeset
|
69 suite.addTest(unittest.makeSuite(MergeResolveTestCase)) |
26
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
70 return suite |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
71 |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
72 if __name__ == '__main__': |
710090104678
* Reduce size of locale data pickles by only storing the data provided by each locale itself, and merging inherited data at runtime.
cmlenz
parents:
diff
changeset
|
73 unittest.main(defaultTest='suite') |