zope.i18n 5.0__py3-none-any.whl → 5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. zope/i18n/format.py +2 -1
  2. zope/i18n/gettextmessagecatalog.py +2 -2
  3. zope/i18n/locales/__init__.py +23 -23
  4. zope/i18n/locales/fallbackcollator.txt +3 -3
  5. zope/i18n/locales/tests/test_docstrings.py +3 -4
  6. zope/i18n/locales/tests/test_fallbackcollator.py +1 -7
  7. zope/i18n/locales/xmlfactory.py +123 -123
  8. zope/i18n/testing.py +11 -12
  9. zope/i18n/testmessagecatalog.py +2 -2
  10. zope/i18n/tests/locale/de/LC_MESSAGES/zope-i18n.mo +0 -0
  11. zope/i18n/tests/locale/en/LC_MESSAGES/zope-i18n.mo +0 -0
  12. zope/i18n/tests/locale-alt/en/LC_MESSAGES/alt.mo +0 -0
  13. zope/i18n/tests/locale-default/de/LC_MESSAGES/default.mo +0 -0
  14. zope/i18n/tests/locale-default/en/LC_MESSAGES/default.mo +0 -0
  15. zope/i18n/tests/locale-default/pl/LC_MESSAGES/default.mo +0 -0
  16. zope/i18n/tests/locale-default/sr/LC_MESSAGES/default.mo +0 -0
  17. zope/i18n/tests/locale-default/sr@Cyrl/LC_MESSAGES/default.mo +0 -0
  18. zope/i18n/tests/locale-default/sr@Latn/LC_MESSAGES/default.mo +0 -0
  19. zope/i18n/tests/locale2/en/LC_MESSAGES/zope-i18n.mo +0 -0
  20. zope/i18n/tests/locale3/en/LC_MESSAGES/zope-i18n.mo +0 -0
  21. zope/i18n/tests/locale3/en/LC_MESSAGES/zope-i18n2.mo +0 -0
  22. zope/i18n/tests/test.py +1 -4
  23. zope/i18n/tests/test_formats.py +603 -714
  24. zope/i18n/tests/test_gettextmessagecatalog.py +4 -1
  25. zope/i18n/tests/test_plurals.py +7 -2
  26. zope/i18n/tests/test_translationdomain.py +37 -19
  27. {zope.i18n-5.0.dist-info → zope.i18n-5.2.dist-info}/METADATA +21 -4
  28. {zope.i18n-5.0.dist-info → zope.i18n-5.2.dist-info}/RECORD +40 -28
  29. {zope.i18n-5.0.dist-info → zope.i18n-5.2.dist-info}/WHEEL +1 -1
  30. /zope/i18n/tests/{en-alt.po → locale-alt/en/LC_MESSAGES/alt.po} +0 -0
  31. /zope/i18n/tests/{de-default.po → locale-default/de/LC_MESSAGES/default.po} +0 -0
  32. /zope/i18n/tests/{en-default.po → locale-default/en/LC_MESSAGES/default.po} +0 -0
  33. /zope/i18n/tests/{pl-default.po → locale-default/pl/LC_MESSAGES/default.po} +0 -0
  34. /zope/i18n/tests/{sr-default.po → locale-default/sr/LC_MESSAGES/default.po} +0 -0
  35. /zope/i18n/tests/{sr@Cyrl-default.po → locale-default/sr@Cyrl/LC_MESSAGES/default.po} +0 -0
  36. /zope/i18n/tests/{sr@Latn-default.po → locale-default/sr@Latn/LC_MESSAGES/default.po} +0 -0
  37. /zope.i18n-5.0-py3.9-nspkg.pth → /zope.i18n-5.2-py3.11-nspkg.pth +0 -0
  38. {zope.i18n-5.0.dist-info → zope.i18n-5.2.dist-info}/LICENSE.txt +0 -0
  39. {zope.i18n-5.0.dist-info → zope.i18n-5.2.dist-info}/namespace_packages.txt +0 -0
  40. {zope.i18n-5.0.dist-info → zope.i18n-5.2.dist-info}/top_level.txt +0 -0
@@ -61,7 +61,7 @@ class LocaleFactory:
61
61
 
62
62
  >>> factory = LocaleFactory(None)
63
63
  >>> from xml.dom.minidom import parseString
64
- >>> xml = u'''
64
+ >>> xml = '''
65
65
  ... <identity>
66
66
  ... <version number="1.0">Some notes</version>
67
67
  ... <generation date="2003-12-19" />
@@ -72,11 +72,11 @@ class LocaleFactory:
72
72
 
73
73
  >>> version = factory._extractVersion(dom.documentElement)
74
74
  >>> version.number
75
- u'1.0'
75
+ '1.0'
76
76
  >>> version.generationDate
77
77
  datetime.date(2003, 12, 19)
78
78
  >>> version.notes
79
- u'Some notes'
79
+ 'Some notes'
80
80
  """
81
81
  number = generationDate = notes = None
82
82
  # Retrieve the version number and notes of the locale
@@ -99,7 +99,7 @@ class LocaleFactory:
99
99
  Example::
100
100
 
101
101
  >>> from xml.dom.minidom import parseString
102
- >>> xml = u'''
102
+ >>> xml = '''
103
103
  ... <ldml>
104
104
  ... <identity>
105
105
  ... <version number="1.0"/>
@@ -114,15 +114,15 @@ class LocaleFactory:
114
114
 
115
115
  >>> id = factory._extractIdentity()
116
116
  >>> id.language
117
- u'en'
117
+ 'en'
118
118
  >>> id.script is None
119
119
  True
120
120
  >>> id.territory
121
- u'US'
121
+ 'US'
122
122
  >>> id.variant
123
- u'POSIX'
123
+ 'POSIX'
124
124
  >>> id.version.number
125
- u'1.0'
125
+ '1.0'
126
126
  """
127
127
  id = LocaleIdentity()
128
128
  identity = self._data.getElementsByTagName('identity')[0]
@@ -149,7 +149,7 @@ class LocaleFactory:
149
149
 
150
150
  >>> factory = LocaleFactory(None)
151
151
  >>> from xml.dom.minidom import parseString
152
- >>> xml = u'''
152
+ >>> xml = '''
153
153
  ... <displayNames>
154
154
  ... <types>
155
155
  ... <type type="Fallback" key="calendar"></type>
@@ -166,15 +166,15 @@ class LocaleFactory:
166
166
  >>> keys = types.keys()
167
167
  >>> keys.sort()
168
168
  >>> keys[:2]
169
- [(u'Fallback', u'calendar'), (u'buddhist', u'calendar')]
169
+ [('Fallback', 'calendar'), ('buddhist', 'calendar')]
170
170
  >>> keys[2:4]
171
- [(u'chinese', u'calendar'), (u'gregorian', u'calendar')]
171
+ [('chinese', 'calendar'), ('gregorian', 'calendar')]
172
172
  >>> keys[4:]
173
- [(u'stroke', u'collation'), (u'traditional', u'collation')]
174
- >>> types[(u'chinese', u'calendar')]
175
- u'CHINESE'
176
- >>> types[(u'stroke', u'collation')]
177
- u'STROKE'
173
+ [('stroke', 'collation'), ('traditional', 'collation')]
174
+ >>> types[('chinese', 'calendar')]
175
+ 'CHINESE'
176
+ >>> types[('stroke', 'collation')]
177
+ 'STROKE'
178
178
  """
179
179
  # 'types' node has not to exist
180
180
  types_nodes = names_node.getElementsByTagName('types')
@@ -194,7 +194,7 @@ class LocaleFactory:
194
194
  Example::
195
195
 
196
196
  >>> from xml.dom.minidom import parseString
197
- >>> xml = u'''
197
+ >>> xml = '''
198
198
  ... <ldml>
199
199
  ... <localeDisplayNames>
200
200
  ... <languages>
@@ -232,40 +232,40 @@ class LocaleFactory:
232
232
  >>> keys = names.languages.keys()
233
233
  >>> keys.sort()
234
234
  >>> keys
235
- [u'Fallback', u'aa', u'ab']
236
- >>> names.languages[u"aa"]
237
- u'aa'
235
+ ['Fallback', 'aa', 'ab']
236
+ >>> names.languages["aa"]
237
+ 'aa'
238
238
 
239
239
  >>> keys = names.scripts.keys()
240
240
  >>> keys.sort()
241
241
  >>> keys
242
- [u'Arab', u'Armn']
243
- >>> names.scripts[u"Arab"]
244
- u'Arab'
242
+ ['Arab', 'Armn']
243
+ >>> names.scripts["Arab"]
244
+ 'Arab'
245
245
 
246
246
  >>> keys = names.territories.keys()
247
247
  >>> keys.sort()
248
248
  >>> keys
249
- [u'AD', u'AE']
250
- >>> names.territories[u"AD"]
251
- u'AD'
249
+ ['AD', 'AE']
250
+ >>> names.territories["AD"]
251
+ 'AD'
252
252
 
253
253
  >>> keys = names.variants.keys()
254
254
  >>> keys.sort()
255
255
  >>> keys
256
- [u'Fallback', u'POSIX']
257
- >>> names.variants[u"Fallback"]
258
- u''
256
+ ['Fallback', 'POSIX']
257
+ >>> names.variants["Fallback"]
258
+ ''
259
259
 
260
260
  >>> keys = names.keys.keys()
261
261
  >>> keys.sort()
262
262
  >>> keys
263
- [u'calendar', u'collation']
264
- >>> names.keys[u"calendar"]
265
- u'CALENDAR'
263
+ ['calendar', 'collation']
264
+ >>> names.keys["calendar"]
265
+ 'CALENDAR'
266
266
 
267
- >>> names.types[(u"stroke", u"collation")]
268
- u'STROKE'
267
+ >>> names.types[("stroke", "collation")]
268
+ 'STROKE'
269
269
  """
270
270
  displayNames = LocaleDisplayNames()
271
271
  # Neither the 'localeDisplayNames' or 'scripts' node has to exist
@@ -303,7 +303,7 @@ class LocaleFactory:
303
303
  >>> calendar = CalendarStub()
304
304
  >>> factory = LocaleFactory(None)
305
305
  >>> from xml.dom.minidom import parseString
306
- >>> xml = u'''
306
+ >>> xml = '''
307
307
  ... <months>
308
308
  ... <default type="format" />
309
309
  ... <monthContext type="format">
@@ -345,46 +345,46 @@ class LocaleFactory:
345
345
  of getting month names is like this::
346
346
 
347
347
  >>> calendar.defaultMonthContext
348
- u'format'
348
+ 'format'
349
349
 
350
- >>> ctx = calendar.monthContexts[u"format"]
350
+ >>> ctx = calendar.monthContexts["format"]
351
351
  >>> ctx.defaultWidth
352
- u'wide'
352
+ 'wide'
353
353
 
354
- >>> names = [ctx.months[u"wide"][type] for type in range(1,13)]
354
+ >>> names = [ctx.months["wide"][type] for type in range(1,13)]
355
355
  >>> names[:7]
356
- [u'Januar', u'Februar', u'Maerz', u'April', u'Mai', u'Juni', u'Juli']
356
+ ['Januar', 'Februar', 'Maerz', 'April', 'Mai', 'Juni', 'Juli']
357
357
  >>> names[7:]
358
- [u'August', u'September', u'Oktober', u'November', u'Dezember']
358
+ ['August', 'September', 'Oktober', 'November', 'Dezember']
359
359
 
360
- >>> abbrs = [ctx.months[u"abbreviated"][type]
360
+ >>> abbrs = [ctx.months["abbreviated"][type]
361
361
  ... for type in range(1,13)]
362
362
  >>> abbrs[:6]
363
- [u'Jan', u'Feb', u'Mrz', u'Apr', u'Mai', u'Jun']
363
+ ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun']
364
364
  >>> abbrs[6:]
365
- [u'Jul', u'Aug', u'Sep', u'Okt', u'Nov', u'Dez']
365
+ ['Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
366
366
 
367
367
  The old, CLDR 1.0 way of getting month names and abbreviations::
368
368
 
369
369
  >>> names = [calendar.months.get(type, (None, None))[0]
370
370
  ... for type in range(1, 13)]
371
371
  >>> names[:7]
372
- [u'Januar', u'Februar', u'Maerz', u'April', u'Mai', u'Juni', u'Juli']
372
+ ['Januar', 'Februar', 'Maerz', 'April', 'Mai', 'Juni', 'Juli']
373
373
  >>> names[7:]
374
- [u'August', u'September', u'Oktober', u'November', u'Dezember']
374
+ ['August', 'September', 'Oktober', 'November', 'Dezember']
375
375
 
376
376
  >>> abbrs = [calendar.months.get(type, (None, None))[1]
377
377
  ... for type in range(1, 13)]
378
378
  >>> abbrs[:6]
379
- [u'Jan', u'Feb', u'Mrz', u'Apr', u'Mai', u'Jun']
379
+ ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun']
380
380
  >>> abbrs[6:]
381
- [u'Jul', u'Aug', u'Sep', u'Okt', u'Nov', u'Dez']
381
+ ['Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
382
382
 
383
383
  If there are no months, nothing happens:
384
384
 
385
385
  >>> calendar = CalendarStub()
386
386
  >>> factory = LocaleFactory(None)
387
- >>> xml = u'''<months><default type="format" /></months>'''
387
+ >>> xml = '''<months><default type="format" /></months>'''
388
388
  >>> dom = parseString(xml)
389
389
  >>> factory._extractMonths(dom.documentElement, calendar)
390
390
  >>> calendar.months
@@ -461,7 +461,7 @@ class LocaleFactory:
461
461
  >>> calendar = CalendarStub()
462
462
  >>> factory = LocaleFactory(None)
463
463
  >>> from xml.dom.minidom import parseString
464
- >>> xml = u'''
464
+ >>> xml = '''
465
465
  ... <days>
466
466
  ... <default type="format" />
467
467
  ... <dayContext type="format">
@@ -493,21 +493,21 @@ class LocaleFactory:
493
493
  how to use them::
494
494
 
495
495
  >>> calendar.defaultDayContext
496
- u'format'
496
+ 'format'
497
497
 
498
- >>> ctx = calendar.dayContexts[u"format"]
498
+ >>> ctx = calendar.dayContexts["format"]
499
499
  >>> ctx.defaultWidth
500
- u'wide'
500
+ 'wide'
501
501
 
502
- >>> names = [ctx.days[u"wide"][type] for type in range(1,8)]
502
+ >>> names = [ctx.days["wide"][type] for type in range(1,8)]
503
503
  >>> names[:4]
504
- [u'Montag', u'Dienstag', u'Mittwoch', u'Donnerstag']
504
+ ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag']
505
505
  >>> names[4:]
506
- [u'Freitag', u'Samstag', u'Sonntag']
506
+ ['Freitag', 'Samstag', 'Sonntag']
507
507
 
508
- >>> abbrs = [ctx.days[u"abbreviated"][type] for type in range(1,8)]
508
+ >>> abbrs = [ctx.days["abbreviated"][type] for type in range(1,8)]
509
509
  >>> abbrs
510
- [u'Mo', u'Di', u'Mi', u'Do', u'Fr', u'Sa', u'So']
510
+ ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']
511
511
 
512
512
  And here's the old CLDR 1.0 way of getting day names and
513
513
  abbreviations::
@@ -515,20 +515,20 @@ class LocaleFactory:
515
515
  >>> names = [calendar.days.get(type, (None, None))[0]
516
516
  ... for type in range(1, 8)]
517
517
  >>> names[:4]
518
- [u'Montag', u'Dienstag', u'Mittwoch', u'Donnerstag']
518
+ ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag']
519
519
  >>> names[4:]
520
- [u'Freitag', u'Samstag', u'Sonntag']
520
+ ['Freitag', 'Samstag', 'Sonntag']
521
521
 
522
522
  >>> abbrs = [calendar.days.get(type, (None, None))[1]
523
523
  ... for type in range(1, 8)]
524
524
  >>> abbrs
525
- [u'Mo', u'Di', u'Mi', u'Do', u'Fr', u'Sa', u'So']
525
+ ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']
526
526
 
527
527
  If there are no days, nothing happens:
528
528
 
529
529
  >>> calendar = CalendarStub()
530
530
  >>> factory = LocaleFactory(None)
531
- >>> xml = u'''<days><default type="format" /></days>'''
531
+ >>> xml = '''<days><default type="format" /></days>'''
532
532
  >>> dom = parseString(xml)
533
533
  >>> factory._extractDays(dom.documentElement, calendar)
534
534
  >>> calendar.days
@@ -604,7 +604,7 @@ class LocaleFactory:
604
604
  >>> calendar = CalendarStub()
605
605
  >>> factory = LocaleFactory(None)
606
606
  >>> from xml.dom.minidom import parseString
607
- >>> xml = u'''
607
+ >>> xml = '''
608
608
  ... <calendar type="gregorian">
609
609
  ... <week>
610
610
  ... <minDays count="1"/>
@@ -663,7 +663,7 @@ class LocaleFactory:
663
663
  >>> calendar = CalendarStub()
664
664
  >>> factory = LocaleFactory(None)
665
665
  >>> from xml.dom.minidom import parseString
666
- >>> xml = u'''
666
+ >>> xml = '''
667
667
  ... <calendar type="gregorian">
668
668
  ... <eras>
669
669
  ... <eraAbbr>
@@ -681,12 +681,12 @@ class LocaleFactory:
681
681
  >>> names = [calendar.eras.get(type, (None, None))[0]
682
682
  ... for type in range(2)]
683
683
  >>> names
684
- [u'Before Christ', None]
684
+ ['Before Christ', None]
685
685
 
686
686
  >>> abbrs = [calendar.eras.get(type, (None, None))[1]
687
687
  ... for type in range(2)]
688
688
  >>> abbrs
689
- [u'BC', u'AD']
689
+ ['BC', 'AD']
690
690
  """
691
691
  # See whether we have era names and abbreviations
692
692
  eras_nodes = cal_node.getElementsByTagName('eras')
@@ -721,7 +721,7 @@ class LocaleFactory:
721
721
 
722
722
  >>> factory = LocaleFactory(None)
723
723
  >>> from xml.dom.minidom import parseString
724
- >>> xml = u'''
724
+ >>> xml = '''
725
725
  ... <dateFormats>
726
726
  ... <default type="medium"/>
727
727
  ... <dateFormatLength type="full">
@@ -745,15 +745,15 @@ class LocaleFactory:
745
745
  >>> default, lengths = factory._extractFormats(
746
746
  ... dom.documentElement, 'dateFormatLength', 'dateFormat')
747
747
  >>> default
748
- u'medium'
749
- >>> lengths[u"full"].formats[None].pattern
750
- u'EEEE, MMMM d, yyyy'
751
- >>> lengths[u"medium"].default
752
- u'DateFormatsKey2'
753
- >>> lengths[u"medium"].formats['DateFormatsKey3'].pattern
754
- u'MMM dd, yyyy'
755
- >>> lengths[u"medium"].formats['DateFormatsKey2'].displayName
756
- u'Standard Date'
748
+ 'medium'
749
+ >>> lengths["full"].formats[None].pattern
750
+ 'EEEE, MMMM d, yyyy'
751
+ >>> lengths["medium"].default
752
+ 'DateFormatsKey2'
753
+ >>> lengths["medium"].formats['DateFormatsKey3'].pattern
754
+ 'MMM dd, yyyy'
755
+ >>> lengths["medium"].formats['DateFormatsKey2'].displayName
756
+ 'Standard Date'
757
757
  """
758
758
  formats_default = None
759
759
  default_nodes = formats_node.getElementsByTagName('default')
@@ -796,7 +796,7 @@ class LocaleFactory:
796
796
 
797
797
  >>> factory = LocaleFactory(None)
798
798
  >>> from xml.dom.minidom import parseString
799
- >>> xml = u'''
799
+ >>> xml = '''
800
800
  ... <dates>
801
801
  ... <calendars>
802
802
  ... <calendar type="gregorian">
@@ -864,7 +864,7 @@ class LocaleFactory:
864
864
  >>> keys = calendars.keys()
865
865
  >>> keys.sort()
866
866
  >>> keys
867
- [u'buddhist', u'gregorian', 'thai-buddhist']
867
+ ['buddhist', 'gregorian', 'thai-buddhist']
868
868
 
869
869
  Note that "thai-buddhist" are added as an alias to "buddhist".
870
870
 
@@ -873,7 +873,7 @@ class LocaleFactory:
873
873
 
874
874
  If there are no calendars, nothing happens:
875
875
 
876
- >>> xml = u'''<dates />'''
876
+ >>> xml = '''<dates />'''
877
877
  >>> dom = parseString(xml)
878
878
  >>> factory._extractCalendars(dom.documentElement)
879
879
 
@@ -943,7 +943,7 @@ class LocaleFactory:
943
943
 
944
944
  >>> factory = LocaleFactory(None)
945
945
  >>> from xml.dom.minidom import parseString
946
- >>> xml = u'''
946
+ >>> xml = '''
947
947
  ... <dates>
948
948
  ... <timeZoneNames>
949
949
  ... <zone type="America/Los_Angeles" >
@@ -975,13 +975,13 @@ class LocaleFactory:
975
975
  >>> keys = zones.keys()
976
976
  >>> keys.sort()
977
977
  >>> keys
978
- [u'America/Los_Angeles', u'Europe/London']
979
- >>> zones[u"Europe/London"].names[u"generic"]
980
- (u'British Time', None)
981
- >>> zones[u"Europe/London"].cities
982
- [u'York']
983
- >>> zones[u"America/Los_Angeles"].names[u"generic"]
984
- (u'Pacific Time', u'PT')
978
+ ['America/Los_Angeles', 'Europe/London']
979
+ >>> zones["Europe/London"].names["generic"]
980
+ ('British Time', None)
981
+ >>> zones["Europe/London"].cities
982
+ ['York']
983
+ >>> zones["America/Los_Angeles"].names["generic"]
984
+ ('Pacific Time', 'PT')
985
985
  """
986
986
  tz_names = dates_node.getElementsByTagName('timeZoneNames')
987
987
  if not tz_names:
@@ -1041,7 +1041,7 @@ class LocaleFactory:
1041
1041
 
1042
1042
  >>> factory = LocaleFactory(None)
1043
1043
  >>> from xml.dom.minidom import parseString
1044
- >>> xml = u'''
1044
+ >>> xml = '''
1045
1045
  ... <numbers>
1046
1046
  ... <symbols>
1047
1047
  ... <decimal>.</decimal>
@@ -1062,15 +1062,15 @@ class LocaleFactory:
1062
1062
  >>> symbols = factory._extractSymbols(dom.documentElement)
1063
1063
 
1064
1064
  >>> symbols['list']
1065
- u';'
1065
+ ';'
1066
1066
  >>> keys = symbols.keys()
1067
1067
  >>> keys.sort()
1068
1068
  >>> keys[:5]
1069
- [u'decimal', u'exponential', u'group', u'infinity', u'list']
1069
+ ['decimal', 'exponential', 'group', 'infinity', 'list']
1070
1070
  >>> keys[5:9]
1071
- [u'minusSign', u'nan', u'nativeZeroDigit', u'patternDigit']
1071
+ ['minusSign', 'nan', 'nativeZeroDigit', 'patternDigit']
1072
1072
  >>> keys[9:]
1073
- [u'perMille', u'percentSign', u'plusSign']
1073
+ ['perMille', 'percentSign', 'plusSign']
1074
1074
  """
1075
1075
  # See whether we have symbols entries
1076
1076
  symbols_nodes = numbers_node.getElementsByTagName('symbols')
@@ -1106,7 +1106,7 @@ class LocaleFactory:
1106
1106
  >>> numbers = Numbers()
1107
1107
  >>> factory = LocaleFactory(None)
1108
1108
  >>> from xml.dom.minidom import parseString
1109
- >>> xml = u'''
1109
+ >>> xml = '''
1110
1110
  ... <numbers>
1111
1111
  ... <decimalFormats>
1112
1112
  ... <decimalFormatLength type="long">
@@ -1146,24 +1146,24 @@ class LocaleFactory:
1146
1146
  >>> dom = parseString(xml)
1147
1147
  >>> factory._extractNumberFormats(dom.documentElement, numbers)
1148
1148
 
1149
- >>> numbers.decimalFormats[u"long"].formats[None].pattern
1150
- u'#,##0.###'
1149
+ >>> numbers.decimalFormats["long"].formats[None].pattern
1150
+ '#,##0.###'
1151
1151
 
1152
1152
  >>> numbers.defaultScientificFormat
1153
- u'long'
1154
- >>> numbers.scientificFormats[u"long"].formats[None].pattern
1155
- u'0.000###E+00'
1156
- >>> numbers.scientificFormats[u"medium"].formats[None].pattern
1157
- u'0.00##E+00'
1158
-
1159
- >>> numbers.percentFormats[u"long"].formats[None].pattern
1160
- u'#,##0%'
1161
- >>> numbers.percentFormats.get(u"medium", None) is None
1153
+ 'long'
1154
+ >>> numbers.scientificFormats["long"].formats[None].pattern
1155
+ '0.000###E+00'
1156
+ >>> numbers.scientificFormats["medium"].formats[None].pattern
1157
+ '0.00##E+00'
1158
+
1159
+ >>> numbers.percentFormats["long"].formats[None].pattern
1160
+ '#,##0%'
1161
+ >>> numbers.percentFormats.get("medium", None) is None
1162
1162
  True
1163
1163
 
1164
- >>> numbers.currencyFormats[u"long"].formats[None].pattern
1165
- u'$ #,##0.00;($ #,##0.00)'
1166
- >>> numbers.currencyFormats.get(u"medium", None) is None
1164
+ >>> numbers.currencyFormats["long"].formats[None].pattern
1165
+ '$ #,##0.00;($ #,##0.00)'
1166
+ >>> numbers.currencyFormats.get("medium", None) is None
1167
1167
  True
1168
1168
  """
1169
1169
 
@@ -1188,7 +1188,7 @@ class LocaleFactory:
1188
1188
 
1189
1189
  >>> factory = LocaleFactory(None)
1190
1190
  >>> from xml.dom.minidom import parseString
1191
- >>> xml = u'''
1191
+ >>> xml = '''
1192
1192
  ... <numbers>
1193
1193
  ... <currencies>
1194
1194
  ... <currency type="USD">
@@ -1215,12 +1215,12 @@ class LocaleFactory:
1215
1215
  >>> keys = currencies.keys()
1216
1216
  >>> keys.sort()
1217
1217
  >>> keys
1218
- [u'INR', u'JPY', u'PTE', u'USD']
1218
+ ['INR', 'JPY', 'PTE', 'USD']
1219
1219
 
1220
1220
  >>> currencies['USD'].symbol
1221
- u'$'
1221
+ '$'
1222
1222
  >>> currencies['USD'].displayName
1223
- u'Dollar'
1223
+ 'Dollar'
1224
1224
  >>> currencies['USD'].symbolChoice
1225
1225
  False
1226
1226
  """
@@ -1270,7 +1270,7 @@ class LocaleFactory:
1270
1270
 
1271
1271
  >>> factory = LocaleFactory(None)
1272
1272
  >>> from xml.dom.minidom import parseString
1273
- >>> xml = u'''
1273
+ >>> xml = '''
1274
1274
  ... <ldml>
1275
1275
  ... <delimiters>
1276
1276
  ... <quotationStart>``</quotationStart>
@@ -1290,14 +1290,14 @@ class LocaleFactory:
1290
1290
  >>> factory._data = parseString(xml).documentElement
1291
1291
  >>> delimiters = factory._extractDelimiters()
1292
1292
 
1293
- >>> delimiters[u"quotationStart"]
1294
- u'``'
1295
- >>> delimiters[u"quotationEnd"]
1296
- u"''"
1297
- >>> delimiters[u"alternateQuotationStart"]
1298
- u'`'
1299
- >>> delimiters[u"alternateQuotationEnd"]
1300
- u"'"
1293
+ >>> delimiters["quotationStart"]
1294
+ '``'
1295
+ >>> delimiters["quotationEnd"]
1296
+ "''"
1297
+ >>> delimiters["alternateQuotationStart"]
1298
+ '`'
1299
+ >>> delimiters["alternateQuotationEnd"]
1300
+ "'"
1301
1301
 
1302
1302
  Escape: "'"
1303
1303
 
@@ -1323,7 +1323,7 @@ class LocaleFactory:
1323
1323
 
1324
1324
  >>> factory = LocaleFactory(None)
1325
1325
  >>> from xml.dom.minidom import parseString
1326
- >>> xml = u'''
1326
+ >>> xml = '''
1327
1327
  ... <ldml>
1328
1328
  ... <layout>
1329
1329
  ... <orientation lines="bottom-to-top"
@@ -1334,9 +1334,9 @@ class LocaleFactory:
1334
1334
  >>> factory._data = parseString(xml).documentElement
1335
1335
  >>> orientation = factory._extractOrientation()
1336
1336
  >>> orientation.lines
1337
- u'bottom-to-top'
1337
+ 'bottom-to-top'
1338
1338
  >>> orientation.characters
1339
- u'right-to-left'
1339
+ 'right-to-left'
1340
1340
  """
1341
1341
  orientation_nodes = self._data.getElementsByTagName('orientation')
1342
1342
  if not orientation_nodes:
zope/i18n/testing.py CHANGED
@@ -16,19 +16,9 @@ Unit test logic for setting up and tearing down basic infrastructure.
16
16
 
17
17
  This relies on :mod:`zope.publisher` being available.
18
18
  """
19
+ import os.path
19
20
 
20
- import re
21
-
22
- from zope.testing import renormalizing
23
-
24
-
25
- rules = []
26
- if bytes is not str:
27
- rules = [
28
- (re.compile("u('.*?')"), r"\1"),
29
- (re.compile('u(".*?")'), r"\1"),
30
- ]
31
- unicode_checker = renormalizing.RENormalizing(rules)
21
+ from pythongettext.msgfmt import Msgfmt
32
22
 
33
23
 
34
24
  def setUp(test=None):
@@ -57,3 +47,12 @@ class PlacelessSetup:
57
47
 
58
48
  """
59
49
  setUp()
50
+
51
+
52
+ def compile_po(mo_path):
53
+ """If `mo_path` does not exist, compile its po file."""
54
+ if not os.path.exists(mo_path): # pragma: no cover
55
+ po_path = mo_path.replace('.mo', '.po')
56
+ mo_content = Msgfmt(po_path, name=po_path).get()
57
+ with open(mo_path, "wb") as mo:
58
+ mo.write(mo_content)
@@ -30,11 +30,11 @@ class TestMessageCatalog:
30
30
  def queryMessage(self, msgid, default=None):
31
31
  default = getattr(msgid, 'default', default)
32
32
  if default is not None and default != msgid:
33
- msg = "{} ({})".format(msgid, default)
33
+ msg = f"{msgid} ({default})"
34
34
  else:
35
35
  msg = msgid
36
36
 
37
- return "[[{}][{}]]".format(self.domain, msg)
37
+ return f"[[{self.domain}][{msg}]]"
38
38
 
39
39
  getMessage = queryMessage
40
40
 
zope/i18n/tests/test.py CHANGED
@@ -19,8 +19,6 @@ import unittest
19
19
  from zope.component.testing import setUp
20
20
  from zope.component.testing import tearDown
21
21
 
22
- from zope.i18n.testing import unicode_checker
23
-
24
22
 
25
23
  def test_suite():
26
24
  options = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
@@ -29,8 +27,7 @@ def test_suite():
29
27
  return doctest.DocTestSuite(
30
28
  name,
31
29
  setUp=setUp, tearDown=tearDown,
32
- optionflags=options,
33
- checker=unicode_checker)
30
+ optionflags=options)
34
31
 
35
32
  return unittest.TestSuite([
36
33
  suite('zope.i18n'),