Commit 169f195b authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #22943: bsddb tests are locale independend now.

This fixes tests on 8-bit locales (in particular on Windows).
parent d5355178
...@@ -412,9 +412,6 @@ if sys.version_info[0] >= 3 : ...@@ -412,9 +412,6 @@ if sys.version_info[0] >= 3 :
def get_dbp(self) : def get_dbp(self) :
return self._db return self._db
import string
string.letters=[chr(i) for i in xrange(65,91)]
bsddb._db.DBEnv_orig = bsddb._db.DBEnv bsddb._db.DBEnv_orig = bsddb._db.DBEnv
bsddb._db.DB_orig = bsddb._db.DB bsddb._db.DB_orig = bsddb._db.DB
if bsddb.db.version() <= (4, 3) : if bsddb.db.version() <= (4, 3) :
......
...@@ -999,7 +999,7 @@ class BasicMultiDBTestCase(BasicTestCase): ...@@ -999,7 +999,7 @@ class BasicMultiDBTestCase(BasicTestCase):
for x in "The quick brown fox jumped over the lazy dog".split(): for x in "The quick brown fox jumped over the lazy dog".split():
d2.put(x, self.makeData(x)) d2.put(x, self.makeData(x))
for x in string.letters: for x in string.ascii_letters:
d3.put(x, x*70) d3.put(x, x*70)
d1.sync() d1.sync()
...@@ -1047,7 +1047,7 @@ class BasicMultiDBTestCase(BasicTestCase): ...@@ -1047,7 +1047,7 @@ class BasicMultiDBTestCase(BasicTestCase):
if verbose: if verbose:
print rec print rec
rec = c3.next() rec = c3.next()
self.assertEqual(count, len(string.letters)) self.assertEqual(count, len(string.ascii_letters))
c1.close() c1.close()
......
...@@ -59,7 +59,7 @@ class DBShelveTestCase(unittest.TestCase): ...@@ -59,7 +59,7 @@ class DBShelveTestCase(unittest.TestCase):
return bytes(key, "iso8859-1") # 8 bits return bytes(key, "iso8859-1") # 8 bits
def populateDB(self, d): def populateDB(self, d):
for x in string.letters: for x in string.ascii_letters:
d[self.mk('S' + x)] = 10 * x # add a string d[self.mk('S' + x)] = 10 * x # add a string
d[self.mk('I' + x)] = ord(x) # add an integer d[self.mk('I' + x)] = ord(x) # add an integer
d[self.mk('L' + x)] = [x] * 10 # add a list d[self.mk('L' + x)] = [x] * 10 # add a list
......
...@@ -26,14 +26,14 @@ class GetReturnsNoneTestCase(unittest.TestCase): ...@@ -26,14 +26,14 @@ class GetReturnsNoneTestCase(unittest.TestCase):
d.open(self.filename, db.DB_BTREE, db.DB_CREATE) d.open(self.filename, db.DB_BTREE, db.DB_CREATE)
d.set_get_returns_none(1) d.set_get_returns_none(1)
for x in string.letters: for x in string.ascii_letters:
d.put(x, x * 40) d.put(x, x * 40)
data = d.get('bad key') data = d.get('bad key')
self.assertEqual(data, None) self.assertEqual(data, None)
data = d.get(string.letters[0]) data = d.get(string.ascii_letters[0])
self.assertEqual(data, string.letters[0]*40) self.assertEqual(data, string.ascii_letters[0]*40)
count = 0 count = 0
c = d.cursor() c = d.cursor()
...@@ -43,7 +43,7 @@ class GetReturnsNoneTestCase(unittest.TestCase): ...@@ -43,7 +43,7 @@ class GetReturnsNoneTestCase(unittest.TestCase):
rec = c.next() rec = c.next()
self.assertEqual(rec, None) self.assertEqual(rec, None)
self.assertEqual(count, len(string.letters)) self.assertEqual(count, len(string.ascii_letters))
c.close() c.close()
d.close() d.close()
...@@ -54,14 +54,14 @@ class GetReturnsNoneTestCase(unittest.TestCase): ...@@ -54,14 +54,14 @@ class GetReturnsNoneTestCase(unittest.TestCase):
d.open(self.filename, db.DB_BTREE, db.DB_CREATE) d.open(self.filename, db.DB_BTREE, db.DB_CREATE)
d.set_get_returns_none(0) d.set_get_returns_none(0)
for x in string.letters: for x in string.ascii_letters:
d.put(x, x * 40) d.put(x, x * 40)
self.assertRaises(db.DBNotFoundError, d.get, 'bad key') self.assertRaises(db.DBNotFoundError, d.get, 'bad key')
self.assertRaises(KeyError, d.get, 'bad key') self.assertRaises(KeyError, d.get, 'bad key')
data = d.get(string.letters[0]) data = d.get(string.ascii_letters[0])
self.assertEqual(data, string.letters[0]*40) self.assertEqual(data, string.ascii_letters[0]*40)
count = 0 count = 0
exceptionHappened = 0 exceptionHappened = 0
...@@ -77,7 +77,7 @@ class GetReturnsNoneTestCase(unittest.TestCase): ...@@ -77,7 +77,7 @@ class GetReturnsNoneTestCase(unittest.TestCase):
self.assertNotEqual(rec, None) self.assertNotEqual(rec, None)
self.assertTrue(exceptionHappened) self.assertTrue(exceptionHappened)
self.assertEqual(count, len(string.letters)) self.assertEqual(count, len(string.ascii_letters))
c.close() c.close()
d.close() d.close()
......
...@@ -10,7 +10,6 @@ from test_all import db, verbose, get_new_database_path ...@@ -10,7 +10,6 @@ from test_all import db, verbose, get_new_database_path
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@unittest.skip("fails on Windows; see issue 22943")
class SimpleQueueTestCase(unittest.TestCase): class SimpleQueueTestCase(unittest.TestCase):
def setUp(self): def setUp(self):
self.filename = get_new_database_path() self.filename = get_new_database_path()
...@@ -37,17 +36,17 @@ class SimpleQueueTestCase(unittest.TestCase): ...@@ -37,17 +36,17 @@ class SimpleQueueTestCase(unittest.TestCase):
print "before appends" + '-' * 30 print "before appends" + '-' * 30
pprint(d.stat()) pprint(d.stat())
for x in string.letters: for x in string.ascii_letters:
d.append(x * 40) d.append(x * 40)
self.assertEqual(len(d), len(string.letters)) self.assertEqual(len(d), len(string.ascii_letters))
d.put(100, "some more data") d.put(100, "some more data")
d.put(101, "and some more ") d.put(101, "and some more ")
d.put(75, "out of order") d.put(75, "out of order")
d.put(1, "replacement data") d.put(1, "replacement data")
self.assertEqual(len(d), len(string.letters)+3) self.assertEqual(len(d), len(string.ascii_letters)+3)
if verbose: if verbose:
print "before close" + '-' * 30 print "before close" + '-' * 30
...@@ -108,17 +107,17 @@ class SimpleQueueTestCase(unittest.TestCase): ...@@ -108,17 +107,17 @@ class SimpleQueueTestCase(unittest.TestCase):
print "before appends" + '-' * 30 print "before appends" + '-' * 30
pprint(d.stat()) pprint(d.stat())
for x in string.letters: for x in string.ascii_letters:
d.append(x * 40) d.append(x * 40)
self.assertEqual(len(d), len(string.letters)) self.assertEqual(len(d), len(string.ascii_letters))
d.put(100, "some more data") d.put(100, "some more data")
d.put(101, "and some more ") d.put(101, "and some more ")
d.put(75, "out of order") d.put(75, "out of order")
d.put(1, "replacement data") d.put(1, "replacement data")
self.assertEqual(len(d), len(string.letters)+3) self.assertEqual(len(d), len(string.ascii_letters)+3)
if verbose: if verbose:
print "before close" + '-' * 30 print "before close" + '-' * 30
......
...@@ -4,12 +4,11 @@ ...@@ -4,12 +4,11 @@
import os, sys import os, sys
import errno import errno
from pprint import pprint from pprint import pprint
import string
import unittest import unittest
from test_all import db, test_support, verbose, get_new_environment_path, get_new_database_path from test_all import db, test_support, verbose, get_new_environment_path, get_new_database_path
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
#---------------------------------------------------------------------- #----------------------------------------------------------------------
...@@ -39,7 +38,7 @@ class SimpleRecnoTestCase(unittest.TestCase): ...@@ -39,7 +38,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
d.open(self.filename, db.DB_RECNO, db.DB_CREATE) d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
for x in letters: for x in string.ascii_letters:
recno = d.append(x * 60) recno = d.append(x * 60)
self.assertIsInstance(recno, int) self.assertIsInstance(recno, int)
self.assertGreaterEqual(recno, 1) self.assertGreaterEqual(recno, 1)
...@@ -270,7 +269,7 @@ class SimpleRecnoTestCase(unittest.TestCase): ...@@ -270,7 +269,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
d.set_re_pad(45) # ...test both int and char d.set_re_pad(45) # ...test both int and char
d.open(self.filename, db.DB_RECNO, db.DB_CREATE) d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
for x in letters: for x in string.ascii_letters:
d.append(x * 35) # These will be padded d.append(x * 35) # These will be padded
d.append('.' * 40) # this one will be exact d.append('.' * 40) # this one will be exact
......
...@@ -30,6 +30,11 @@ Tools/Demos ...@@ -30,6 +30,11 @@ Tools/Demos
- Issue #18905: "pydoc -p 0" now outputs actually used port. Based on patch by - Issue #18905: "pydoc -p 0" now outputs actually used port. Based on patch by
Wieland Hoffmann. Wieland Hoffmann.
Tests
-----
- Issue #22943: bsddb tests are locale independend now.
What's New in Python 2.7.9? What's New in Python 2.7.9?
=========================== ===========================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment