Пример #1
0
 def setup_class(cls):
     cls.oldlocale = _locale.setlocale(_locale.LC_NUMERIC)
     if sys.platform.startswith("win"):
         cls.tloc = "en"
     elif sys.platform.startswith("freebsd"):
         cls.tloc = "en_US.US-ASCII"
     else:
         cls.tloc = "en_US.UTF8"
     try:
         _locale.setlocale(_locale.LC_NUMERIC, cls.tloc)
     except _locale.Error:
         py.test.skip("test locale %s not supported" % cls.tloc)
Пример #2
0
 def setup_class(cls):
     cls.oldlocale = _locale.setlocale(_locale.LC_NUMERIC)
     if sys.platform.startswith("win"):
         cls.tloc = "en"
     elif sys.platform.startswith("freebsd"):
         cls.tloc = "en_US.US-ASCII"
     else:
         cls.tloc = "en_US.UTF8"
     try:
         _locale.setlocale(_locale.LC_NUMERIC, cls.tloc)
     except _locale.Error:
         py.test.skip("test locale %s not supported" % cls.tloc)
Пример #3
0
    def test_bsd_bug(self):
        def teststrop(s, method, output):
            print "%s.%s() =? %s ..." % (repr(s), method, repr(output)),
            result = getattr(s, method)()
            assert result == output

        oldlocale = _locale.setlocale(_locale.LC_CTYPE)
        _locale.setlocale(_locale.LC_CTYPE, self.tloc)
        try:
            teststrop('\x20', 'isspace', True)
            teststrop('\xa0', 'isspace', False)
            teststrop('\xa1', 'isspace', False)
            teststrop('\xc0', 'isalpha', False)
            teststrop('\xc0', 'isalnum', False)
            teststrop('\xc0', 'isupper', False)
            teststrop('\xc0', 'islower', False)
            teststrop('\xec\xa0\xbc', 'split', ['\xec\xa0\xbc'])
            teststrop('\xed\x95\xa0', 'strip', '\xed\x95\xa0')
            teststrop('\xcc\x85', 'lower', '\xcc\x85')
            teststrop('\xed\x95\xa0', 'upper', '\xed\x95\xa0')
        finally:
            _locale.setlocale(_locale.LC_CTYPE, oldlocale)
Пример #4
0
    def test_bsd_bug(self):
        def teststrop(s, method, output):
            print "%s.%s() =? %s ..." % (repr(s), method, repr(output)),
            result = getattr(s, method)()
            assert result == output

        oldlocale = _locale.setlocale(_locale.LC_CTYPE)
        _locale.setlocale(_locale.LC_CTYPE, self.tloc)
        try:
            teststrop('\x20', 'isspace', True)
            teststrop('\xa0', 'isspace', False)
            teststrop('\xa1', 'isspace', False)
            teststrop('\xc0', 'isalpha', False)
            teststrop('\xc0', 'isalnum', False)
            teststrop('\xc0', 'isupper', False)
            teststrop('\xc0', 'islower', False)
            teststrop('\xec\xa0\xbc', 'split', ['\xec\xa0\xbc'])
            teststrop('\xed\x95\xa0', 'strip', '\xed\x95\xa0')
            teststrop('\xcc\x85', 'lower', '\xcc\x85')
            teststrop('\xed\x95\xa0', 'upper', '\xed\x95\xa0')
        finally:
            _locale.setlocale(_locale.LC_CTYPE, oldlocale)
Пример #5
0
 def teardown_class(cls):
     _locale.setlocale(_locale.LC_NUMERIC, cls.oldlocale)
Пример #6
0
 def teardown_class(cls):
     _locale.setlocale(_locale.LC_NUMERIC, cls.oldlocale)