Skip to content
This repository was archived by the owner on Jul 19, 2018. It is now read-only.

Commit 203deb9

Browse files
committed
tests: skip on missing locale
1 parent 2dc8bb9 commit 203deb9

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
six
12
boto
23
hubstorage>=0.23
34
python-dateutil

tests/test_magicfields.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import re, os
23
from unittest import TestCase
34

tests/test_processors.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
from scrapylib.processors import to_datetime, to_date, default_input_processor
77

88

9+
def locale_exists():
10+
current_locale = locale.getlocale(locale.LC_TIME)
11+
try:
12+
locale.setlocale(locale.LC_TIME, 'fr_FR.UTF-8')
13+
except Exception:
14+
return False
15+
else:
16+
locale.setlocale(locale.LC_TIME, current_locale)
17+
return True
18+
19+
920
class TestProcessors(unittest.TestCase):
1021

1122
def test_to_datetime(self):
@@ -20,6 +31,7 @@ def test_to_datetime(self):
2031
self.assertEquals(to_datetime('March 4, 2011', '%B %d, %Y'),
2132
datetime.datetime(2011, 3, 4))
2233

34+
@unittest.skipUnless(locale_exists(), "locale does not exist")
2335
def test_localized_to_datetime(self):
2436
current_locale = locale.getlocale(locale.LC_TIME)
2537

@@ -38,6 +50,7 @@ def test_to_date(self):
3850
test_date = to_date('March 4', '%B %d')
3951
self.assertEquals(test_date.year, datetime.datetime.utcnow().year)
4052

53+
@unittest.skipUnless(locale_exists(), "locale does not exist")
4154
def test_localized_to_date(self):
4255
current_locale = locale.getlocale(locale.LC_TIME)
4356

0 commit comments

Comments
 (0)