Mercurial > babel > old > babel-test
annotate babel/tests/core.py @ 535:2cfe20fd80a0 stable-0.9.x
merge r586 from trunk
author | fschwarz |
---|---|
date | Fri, 11 Mar 2011 16:25:08 +0000 |
parents | a2c54ef107c2 |
children |
rev | line source |
---|---|
1 | 1 # -*- coding: utf-8 -*- |
2 # | |
12
a2c54ef107c2
* Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents:
1
diff
changeset
|
3 # Copyright (C) 2007 Edgewall Software |
1 | 4 # All rights reserved. |
5 # | |
6 # This software is licensed as described in the file COPYING, which | |
7 # you should have received as part of this distribution. The terms | |
8 # are also available at http://babel.edgewall.org/wiki/License. | |
9 # | |
10 # This software consists of voluntary contributions made by many | |
11 # individuals. For the exact contribution history, see the revision | |
12 # history and logs, available at http://babel.edgewall.org/log/. | |
13 | |
14 import doctest | |
535 | 15 import os |
1 | 16 import unittest |
17 | |
18 from babel import core | |
535 | 19 from babel.core import default_locale |
20 | |
21 class DefaultLocaleTest(unittest.TestCase): | |
22 | |
23 def setUp(self): | |
24 self._old_locale_settings = self._current_locale_settings() | |
25 | |
26 def tearDown(self): | |
27 self._set_locale_settings(self._old_locale_settings) | |
28 | |
29 def _current_locale_settings(self): | |
30 settings = {} | |
31 for name in ('LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG'): | |
32 settings[name] = os.environ[name] | |
33 return settings | |
34 | |
35 def _set_locale_settings(self, settings): | |
36 for name, value in settings.items(): | |
37 os.environ[name] = value | |
38 | |
39 def test_ignore_invalid_locales_in_lc_ctype(self): | |
40 # This is a regression test specifically for a bad LC_CTYPE setting on | |
41 # MacOS X 10.6 (#200) | |
42 os.environ['LC_CTYPE'] = 'UTF-8' | |
43 # must not throw an exception | |
44 default_locale('LC_CTYPE') | |
1 | 45 |
46 def suite(): | |
47 suite = unittest.TestSuite() | |
48 suite.addTest(doctest.DocTestSuite(core)) | |
535 | 49 suite.addTest(unittest.makeSuite(DefaultLocaleTest)) |
1 | 50 return suite |
51 | |
52 if __name__ == '__main__': | |
53 unittest.main(defaultTest='suite') |