-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_locale.py
56 lines (43 loc) · 1.28 KB
/
test_locale.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'''Test locale independence of WKT
'''
from . import unittest
import sys
import locale
from shapely.wkt import loads, dumps
# Set locale to one that uses a comma as decimal seperator
# TODO: try a few other common locales
if sys.platform == 'win32':
test_locales = {
'Portuguese': 'portuguese_brazil',
}
else:
test_locales = {
'Portuguese': 'pt_BR.UTF-8',
}
do_test_locale = False
def setUpModule():
global do_test_locale
for name in test_locales:
try:
test_locale = test_locales[name]
locale.setlocale(locale.LC_ALL, test_locale)
do_test_locale = True
break
except:
pass
if not do_test_locale:
raise unittest.SkipTest('test locale not found')
def tearDownModule():
locale.resetlocale()
class LocaleTestCase(unittest.TestCase):
#@unittest.skipIf(not do_test_locale, 'test locale not found')
def test_wkt_locale(self):
# Test reading and writing
p = loads('POINT (0.0 0.0)')
self.assertEqual(p.x, 0.0)
self.assertEqual(p.y, 0.0)
wkt = dumps(p)
self.assertTrue(wkt.startswith('POINT'))
self.assertFalse(',' in wkt)
def test_suite():
return unittest.TestLoader().loadTestsFromTestCase(LocaleTestCase)