Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
test.test__locale._LocaleTests Class Reference
Collaboration diagram for test.test__locale._LocaleTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def setUp
def tearDown
def numeric_tester
def test_lc_numeric_nl_langinfo
def test_lc_numeric_localeconv
def test_lc_numeric_basic
def test_float_parsing

Public Attributes

 oldlocale

Static Public Attributes

string lc_numeric_err_msg = "%s != %s (%s for %s; set to %s, using %s)"

Detailed Description

Definition at line 40 of file test__locale.py.


Member Function Documentation

def test.test__locale._LocaleTests.numeric_tester (   self,
  calc_type,
  calc_value,
  data_type,
  used_locale 
)
Compare calculation against known value, if available

Definition at line 53 of file test__locale.py.

00053 
00054     def numeric_tester(self, calc_type, calc_value, data_type, used_locale):
00055         """Compare calculation against known value, if available"""
00056         try:
00057             set_locale = setlocale(LC_NUMERIC)
00058         except Error:
00059             set_locale = "<not able to determine>"
00060         known_value = known_numerics.get(used_locale,
00061                                     ('', ''))[data_type == 'thousands_sep']
00062         if known_value and calc_value:
00063             self.assertEqual(calc_value, known_value,
00064                                 self.lc_numeric_err_msg % (
00065                                     calc_value, known_value,
00066                                     calc_type, data_type, set_locale,
00067                                     used_locale))

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 42 of file test__locale.py.

00042 
00043     def setUp(self):
00044         self.oldlocale = setlocale(LC_ALL)

Here is the caller graph for this function:

Definition at line 45 of file test__locale.py.

00045 
00046     def tearDown(self):
00047         setlocale(LC_ALL, self.oldlocale)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 116 of file test__locale.py.

00116 
00117     def test_float_parsing(self):
00118         # Bug #1391872: Test whether float parsing is okay on European
00119         # locales.
00120         for loc in candidate_locales:
00121             try:
00122                 setlocale(LC_NUMERIC, loc)
00123                 setlocale(LC_CTYPE, loc)
00124             except Error:
00125                 continue
00126 
00127             # Ignore buggy locale databases. (Mac OS 10.4 and some other BSDs)
00128             if loc == 'eu_ES' and localeconv()['decimal_point'] == "' ":
00129                 continue
00130 
00131             self.assertEqual(int(eval('3.14') * 100), 314,
00132                                 "using eval('3.14') failed for %s" % loc)
00133             self.assertEqual(int(float('3.14') * 100), 314,
00134                                 "using float('3.14') failed for %s" % loc)
00135             if localeconv()['decimal_point'] != '.':
00136                 self.assertRaises(ValueError, float,
00137                                   localeconv()['decimal_point'].join(['1', '23']))

Here is the call graph for this function:

Definition at line 94 of file test__locale.py.

00094 
00095     def test_lc_numeric_basic(self):
00096         # Test nl_langinfo against localeconv
00097         for loc in candidate_locales:
00098             try:
00099                 setlocale(LC_NUMERIC, loc)
00100                 setlocale(LC_CTYPE, loc)
00101             except Error:
00102                 continue
00103             for li, lc in ((RADIXCHAR, "decimal_point"),
00104                             (THOUSEP, "thousands_sep")):
00105                 nl_radixchar = nl_langinfo(li)
00106                 li_radixchar = localeconv()[lc]
00107                 try:
00108                     set_locale = setlocale(LC_NUMERIC)
00109                 except Error:
00110                     set_locale = "<not able to determine>"
00111                 self.assertEqual(nl_radixchar, li_radixchar,
00112                                 "%s (nl_langinfo) != %s (localeconv) "
00113                                 "(set to %s, using %s)" % (
00114                                                 nl_radixchar, li_radixchar,
00115                                                 loc, set_locale))

Here is the call graph for this function:

Definition at line 81 of file test__locale.py.

00081 
00082     def test_lc_numeric_localeconv(self):
00083         # Test localeconv against known values
00084         for loc in candidate_locales:
00085             try:
00086                 setlocale(LC_NUMERIC, loc)
00087                 setlocale(LC_CTYPE, loc)
00088             except Error:
00089                 continue
00090             for lc in ("decimal_point",
00091                         "thousands_sep"):
00092                 self.numeric_tester('localeconv', localeconv()[lc], lc, loc)

Here is the call graph for this function:

Definition at line 69 of file test__locale.py.

00069 
00070     def test_lc_numeric_nl_langinfo(self):
00071         # Test nl_langinfo against known values
00072         for loc in candidate_locales:
00073             try:
00074                 setlocale(LC_NUMERIC, loc)
00075                 setlocale(LC_CTYPE, loc)
00076             except Error:
00077                 continue
00078             for li, lc in ((RADIXCHAR, "decimal_point"),
00079                             (THOUSEP, "thousands_sep")):
00080                 self.numeric_tester('nl_langinfo', nl_langinfo(li), lc, loc)

Here is the call graph for this function:


Member Data Documentation

string test.test__locale._LocaleTests.lc_numeric_err_msg = "%s != %s (%s for %s; set to %s, using %s)" [static]

Definition at line 51 of file test__locale.py.

Definition at line 43 of file test__locale.py.


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