Skip to content

Instantly share code, notes, and snippets.

Last active May 5, 2016 12:44
What would you like to do?
# -*- coding: utf-8 -*-
import sys
import unittest
import locale
import threading
from datetime import date
from contextlib import contextmanager
from orgmode.liborgmode.orgdate import OrgDate
class OrgDateUtf8TestCase(unittest.TestCase):
Tests OrgDate with utf-8 enabled locales
LOCALE_LOCK = threading.Lock()
UTF8_LOCALE = "pt_BR.utf-8"
def setlocale(self, name):
with self.LOCALE_LOCK:
saved = locale.setlocale(locale.LC_ALL)
yield locale.setlocale(locale.LC_ALL, name)
locale.setlocale(locale.LC_ALL, saved)
def setUp(self):
self.year = 2016
self.month = 5 = 7
self.text = u'<2016-05-07 Sáb>'
self.textinactive = u'[2016-05-07 Sáb]'
def test_OrdDate_str_unicode_active(self):
with self.setlocale(self.UTF8_LOCALE):
od = OrgDate(True, self.year, self.month,
self.assertEqual(self.text, unicode(od))
def test_OrdDate_str_unicode_inactive(self):
with self.setlocale(self.UTF8_LOCALE):
od = OrgDate(False, self.year, self.month,
self.assertEqual(self.textinactive, unicode(od))
def suite():
return unittest.TestLoader().loadTestsFromTestCase(OrgDateUtf8TestCase)
# vi: noexpandtab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment