summaryrefslogtreecommitdiff
path: root/test/suite
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@wiredtiger.com>2012-02-08 13:05:42 +1100
committerMichael Cahill <michael.cahill@wiredtiger.com>2012-02-08 13:05:42 +1100
commitb23fd1c0c3f1bd0ddef34c5803d517b53911df2d (patch)
tree1c108238ffd95f4c2eca7b47a9209d6004eb70c5 /test/suite
parent174d166569d53a1c0cee43cd54028a3882173863 (diff)
downloadmongo-b23fd1c0c3f1bd0ddef34c5803d517b53911df2d.tar.gz
Cleanup test imports, use unittest2 if available so tests pass on Python 2.6.
Diffstat (limited to 'test/suite')
-rw-r--r--test/suite/run.py9
-rw-r--r--test/suite/suite_subprocess.py6
-rw-r--r--test/suite/test_base01.py4
-rw-r--r--test/suite/test_base02.py4
-rw-r--r--test/suite/test_base03.py5
-rw-r--r--test/suite/test_base04.py9
-rw-r--r--test/suite/test_base05.py4
-rw-r--r--test/suite/test_base06.py16
-rw-r--r--test/suite/test_compress01.py5
-rw-r--r--test/suite/test_config01.py5
-rw-r--r--test/suite/test_config02.py11
-rw-r--r--test/suite/test_config03.py8
-rw-r--r--test/suite/test_config04.py15
-rw-r--r--test/suite/test_config05.py10
-rw-r--r--test/suite/test_cursor01.py9
-rw-r--r--test/suite/test_cursor02.py1
-rw-r--r--test/suite/test_cursor03.py1
-rw-r--r--test/suite/test_cursor04.py9
-rw-r--r--test/suite/test_cursor05.py5
-rw-r--r--test/suite/test_cursor_tracker.py9
-rw-r--r--test/suite/test_drop_create.py9
-rw-r--r--test/suite/test_index01.py11
-rw-r--r--test/suite/test_priv01.py7
-rw-r--r--test/suite/test_schema01.py5
-rw-r--r--test/suite/test_schema02.py9
-rw-r--r--test/suite/test_schema03.py8
-rw-r--r--test/suite/test_stat01.py5
-rw-r--r--test/suite/test_util01.py7
-rw-r--r--test/suite/test_util02.py7
-rw-r--r--test/suite/test_util03.py4
-rw-r--r--test/suite/test_util04.py9
-rw-r--r--test/suite/test_util05.py10
-rw-r--r--test/suite/test_util06.py10
-rw-r--r--test/suite/test_util07.py7
-rw-r--r--test/suite/test_util08.py4
-rw-r--r--test/suite/test_util09.py7
-rw-r--r--test/suite/test_util10.py7
-rw-r--r--test/suite/test_util11.py7
-rw-r--r--test/suite/test_util12.py8
-rw-r--r--test/suite/wttest.py12
40 files changed, 95 insertions, 203 deletions
diff --git a/test/suite/run.py b/test/suite/run.py
index 577d83c7ce5..1f201774f50 100644
--- a/test/suite/run.py
+++ b/test/suite/run.py
@@ -29,12 +29,7 @@
# parent class for all test cases
#
-import os
-import sys
-import unittest
-import glob
-import re
-import json
+import glob, json, os, re, sys
# Set paths
suitedir = sys.path[0]
@@ -50,6 +45,8 @@ sys.path.append(os.path.join(wt_3rdpartydir, 'testtools-0.9.12'))
sys.path.append(os.path.join(wt_3rdpartydir, 'testscenarios-0.2', 'lib'))
import wttest
+# Use the same version of unittest found by wttest.py
+unittest = wttest.unittest
from testscenarios.scenarios import generate_scenarios
def usage():
diff --git a/test/suite/suite_subprocess.py b/test/suite/suite_subprocess.py
index 065f4c06e09..f61b9cbd589 100644
--- a/test/suite/suite_subprocess.py
+++ b/test/suite/suite_subprocess.py
@@ -29,12 +29,8 @@
# Run a subprocess within the test suite
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
from run import wt_builddir
-import subprocess
-import os
+import os, subprocess
# Used as a 'mixin' class along with a WiredTigerTestCase class
class suite_subprocess:
diff --git a/test/suite/test_base01.py b/test/suite/test_base01.py
index 3dbbc8c5527..4930859180a 100644
--- a/test/suite/test_base01.py
+++ b/test/suite/test_base01.py
@@ -29,9 +29,7 @@
# Basic operations
#
-import unittest
-import wiredtiger
-import wttest
+import wiredtiger, wttest
class test_base01(wttest.WiredTigerTestCase):
"""
diff --git a/test/suite/test_base02.py b/test/suite/test_base02.py
index 1f064da0b84..838bdf89e99 100644
--- a/test/suite/test_base02.py
+++ b/test/suite/test_base02.py
@@ -31,9 +31,7 @@
#### This test has workarounds to allow it to complete, marked with '####' comments
-import unittest
-import wiredtiger
-import wttest
+import wiredtiger, wttest
import json
class test_base02(wttest.WiredTigerTestCase):
diff --git a/test/suite/test_base03.py b/test/suite/test_base03.py
index 6744e65f4db..277938be124 100644
--- a/test/suite/test_base03.py
+++ b/test/suite/test_base03.py
@@ -29,10 +29,7 @@
# Cursor operations
#
-import unittest
-import wiredtiger
-import wttest
-import wtscenario
+import wiredtiger, wttest
class test_base03(wttest.WiredTigerTestCase):
"""
diff --git a/test/suite/test_base04.py b/test/suite/test_base04.py
index b737d32842c..ce946c80986 100644
--- a/test/suite/test_base04.py
+++ b/test/suite/test_base04.py
@@ -29,10 +29,7 @@
# Test that tables are reconciled correctly when they are empty.
#
-import unittest
-import wiredtiger
-from wiredtiger import WT_NOTFOUND
-import wttest
+import wiredtiger, wttest
class test_base04(wttest.WiredTigerTestCase):
'''Test various tree types becoming empty'''
@@ -90,7 +87,7 @@ class test_base04(wttest.WiredTigerTestCase):
def test_empty(self):
'''Create a table, look for a nonexistent key'''
self.create_table()
- self.check_exists('somekey', WT_NOTFOUND)
+ self.check_exists('somekey', wiredtiger.WT_NOTFOUND)
self.drop_table()
def test_insert(self):
@@ -108,7 +105,7 @@ class test_base04(wttest.WiredTigerTestCase):
self.insert('key1', 'value1')
self.check_exists('key1', 0)
self.remove('key1')
- self.check_exists('key1', WT_NOTFOUND)
+ self.check_exists('key1', wiredtiger.WT_NOTFOUND)
self.drop_table()
if __name__ == '__main__':
diff --git a/test/suite/test_base05.py b/test/suite/test_base05.py
index 2fd8ccd4135..667145f2fc3 100644
--- a/test/suite/test_base05.py
+++ b/test/suite/test_base05.py
@@ -29,9 +29,7 @@
# Cursor operations
#
-import unittest
-import wiredtiger
-import wttest
+import wiredtiger, wttest
class test_base05(wttest.WiredTigerTestCase):
"""
diff --git a/test/suite/test_base06.py b/test/suite/test_base06.py
index 8affaf65541..653dce0b6b9 100644
--- a/test/suite/test_base06.py
+++ b/test/suite/test_base06.py
@@ -29,12 +29,8 @@
# session level operations on tables
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
-import time
-import os
+import os, time
+import wiredtiger, wttest
class test_base06(wttest.WiredTigerTestCase):
"""
@@ -71,7 +67,7 @@ class test_base06(wttest.WiredTigerTestCase):
def checkDoesNotExist(self, t):
self.assertFalse(os.path.exists(t + ".wt"))
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
self.session.open_cursor('table:' + t,
None, None))
@@ -93,7 +89,7 @@ class test_base06(wttest.WiredTigerTestCase):
if not cur1 and not cur2:
self.session.truncate('table:' + tablename, None, None, None)
elif beginerror:
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
self.session.truncate(None, cur1, cur2, None))
else:
self.session.truncate(None, cur1, cur2, None)
@@ -150,7 +146,7 @@ class test_base06(wttest.WiredTigerTestCase):
'table:' + self.table_name1, None)
self.checkContents(self.table_name1)
self.checkDoesNotExist(self.table_name2)
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
self.session.rename('table:' + self.table_name2,
'table:' + self.table_name1, None))
@@ -159,7 +155,7 @@ class test_base06(wttest.WiredTigerTestCase):
self.session.drop('table:' + self.table_name1, None)
self.checkDoesNotExist(self.table_name1)
self.session.drop('table:' + self.table_name1, 'force')
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
self.session.drop('table:' + self.table_name1, None))
def test_truncate(self):
diff --git a/test/suite/test_compress01.py b/test/suite/test_compress01.py
index 34e5e0dff76..cbc32de30cc 100644
--- a/test/suite/test_compress01.py
+++ b/test/suite/test_compress01.py
@@ -29,11 +29,8 @@
# Basic operations
#
-import unittest
-import wiredtiger
-import wttest
import os
-import sys
+import wiredtiger, wttest
class test_compress01_base(wttest.WiredTigerTestCase):
"""
diff --git a/test/suite/test_config01.py b/test/suite/test_config01.py
index 4c68635bfad..7fcff6935cd 100644
--- a/test/suite/test_config01.py
+++ b/test/suite/test_config01.py
@@ -29,11 +29,8 @@
# Configuration strings for wiredtiger_open
#
-import unittest
-import wiredtiger
-import wttest
+import wiredtiger, wtscenario, wttest
import test_base03
-import wtscenario
class test_config01(test_base03.test_base03):
scenarios = wtscenario.wtscenario.session_create_scenario()
diff --git a/test/suite/test_config02.py b/test/suite/test_config02.py
index 728adb9c85a..a6b3dfc46d3 100644
--- a/test/suite/test_config02.py
+++ b/test/suite/test_config02.py
@@ -29,11 +29,8 @@
# The home directory for wiredtiger_open
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
import os
+import wiredtiger, wttest
class test_config02(wttest.WiredTigerTestCase):
table_name1 = 'test_config02'
@@ -148,19 +145,19 @@ class test_config02(wttest.WiredTigerTestCase):
# env var, but no open configuration string, should fail
edir = 'envdir'
os.mkdir(edir)
- self.assertRaises(WiredTigerError,
+ self.assertRaises(wiredtiger.WiredTigerError,
lambda: self.common_test(None, edir, None))
def test_home_does_not_exist(self):
dir = 'nondir'
- self.assertRaises(WiredTigerError,
+ self.assertRaises(wiredtiger.WiredTigerError,
lambda: wiredtiger.wiredtiger_open(dir, 'create'))
def test_home_not_writeable(self):
dir = 'subdir'
os.mkdir(dir)
os.chmod(dir, 0555)
- self.assertRaises(WiredTigerError,
+ self.assertRaises(wiredtiger.WiredTigerError,
lambda: wiredtiger.wiredtiger_open(dir, 'create'))
if __name__ == '__main__':
diff --git a/test/suite/test_config03.py b/test/suite/test_config03.py
index 91fced07edd..4d103f3a1d2 100644
--- a/test/suite/test_config03.py
+++ b/test/suite/test_config03.py
@@ -30,12 +30,8 @@
# combined probabilistically.
#
-import unittest
-from wiredtiger import WiredTigerError
-import wiredtiger
-import wttest
+import wiredtiger, wtscenario, wttest
import test_base03
-import wtscenario
class test_config03(test_base03.test_base03):
K = 1024
@@ -125,7 +121,7 @@ class test_config03(test_base03.test_base03):
if expect_fail:
self.verbose(3, 'wiredtiger_open (should fail) with args: ' + args)
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
wiredtiger.wiredtiger_open(dir, args))
args = successargs
diff --git a/test/suite/test_config04.py b/test/suite/test_config04.py
index d22d7cd75cf..c6ba468e3e1 100644
--- a/test/suite/test_config04.py
+++ b/test/suite/test_config04.py
@@ -29,11 +29,8 @@
# Individually test config options
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
import os
+import wiredtiger, wttest
class test_config04(wttest.WiredTigerTestCase):
table_name1 = 'test_config04'
@@ -93,7 +90,7 @@ class test_config04(wttest.WiredTigerTestCase):
self.assertEqual(got_cache, size)
def test_bad_config(self):
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
wiredtiger.wiredtiger_open('.', 'not_valid,another_bad=10'))
def test_cache_size_number(self):
@@ -126,12 +123,12 @@ class test_config04(wttest.WiredTigerTestCase):
self.common_cache_size_test('2T', 2*self.T)
def test_cache_too_small(self):
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
wiredtiger.wiredtiger_open('.', 'create,cache_size=900000'))
def test_cache_too_large(self):
T11 = 11 * self.T # 11 Terabytes
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
wiredtiger.wiredtiger_open('.', 'create,cache_size=' + str(T11)))
def test_eviction(self):
@@ -139,12 +136,12 @@ class test_config04(wttest.WiredTigerTestCase):
# Note
def test_eviction_bad(self):
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
wiredtiger.wiredtiger_open('.', 'create,eviction_target=91,' +
'eviction_trigger=81'))
def test_eviction_bad2(self):
- self.assertRaises(WiredTigerError, lambda:
+ self.assertRaises(wiredtiger.WiredTigerError, lambda:
wiredtiger.wiredtiger_open('.', 'create,eviction_target=86,' +
'eviction_trigger=86'))
diff --git a/test/suite/test_config05.py b/test/suite/test_config05.py
index a34fcb605eb..35f9bd75b82 100644
--- a/test/suite/test_config05.py
+++ b/test/suite/test_config05.py
@@ -29,11 +29,7 @@
# Test multiple connection opens
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
-import os
+import wiredtiger, wttest
class test_config05(wttest.WiredTigerTestCase):
table_name1 = 'test_config05'
@@ -90,8 +86,8 @@ class test_config05(wttest.WiredTigerTestCase):
def test_multi_create(self):
self.conn = wiredtiger.wiredtiger_open('.', 'create')
self.session = self.conn.open_session(None)
- self.assertRaises(WiredTigerError, lambda: wiredtiger.wiredtiger_open
- ('.', 'create'))
+ self.assertRaises(wiredtiger.WiredTigerError,
+ lambda: wiredtiger.wiredtiger_open('.', 'create'))
if __name__ == '__main__':
wttest.run()
diff --git a/test/suite/test_cursor01.py b/test/suite/test_cursor01.py
index ccb62750e25..446be681b6a 100644
--- a/test/suite/test_cursor01.py
+++ b/test/suite/test_cursor01.py
@@ -29,10 +29,7 @@
# Cursor operations
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
+import wiredtiger, wttest
class test_cursor01(wttest.WiredTigerTestCase):
"""
@@ -94,8 +91,8 @@ class test_cursor01(wttest.WiredTigerTestCase):
def assertCursorHasNoKeyValue(self, cursor):
print('Expect to see messages: \'requires key/value to be set\'')
- self.assertRaises(WiredTigerError, cursor.get_key)
- self.assertRaises(WiredTigerError, cursor.get_value)
+ self.assertRaises(wiredtiger.WiredTigerError, cursor.get_key)
+ self.assertRaises(wiredtiger.WiredTigerError, cursor.get_value)
def test_forward_iter(self):
"""
diff --git a/test/suite/test_cursor02.py b/test/suite/test_cursor02.py
index faeda169690..a25d4cfb3aa 100644
--- a/test/suite/test_cursor02.py
+++ b/test/suite/test_cursor02.py
@@ -29,7 +29,6 @@
# Cursor operations on small tables.
#
-import unittest
import wiredtiger
from test_cursor_tracker import TestCursorTracker
diff --git a/test/suite/test_cursor03.py b/test/suite/test_cursor03.py
index c956a26f8d9..91470984725 100644
--- a/test/suite/test_cursor03.py
+++ b/test/suite/test_cursor03.py
@@ -30,7 +30,6 @@
# with key/values of various sizes.
#
-import unittest
import wiredtiger
from test_cursor_tracker import TestCursorTracker
from wtscenario import multiply_scenarios
diff --git a/test/suite/test_cursor04.py b/test/suite/test_cursor04.py
index 4b82fa076c8..b60cc95c2a2 100644
--- a/test/suite/test_cursor04.py
+++ b/test/suite/test_cursor04.py
@@ -29,10 +29,7 @@
# Cursor operations
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
+import wiredtiger, wttest
class test_cursor04(wttest.WiredTigerTestCase):
"""
@@ -143,8 +140,8 @@ class test_cursor04(wttest.WiredTigerTestCase):
self.assertEqual(cursor.search(), wiredtiger.WT_NOTFOUND)
# The key/value should be cleared on NOTFOUND
- self.assertRaises(WiredTigerError, cursor.get_key)
- self.assertRaises(WiredTigerError, cursor.get_value)
+ self.assertRaises(wiredtiger.WiredTigerError, cursor.get_key)
+ self.assertRaises(wiredtiger.WiredTigerError, cursor.get_value)
# 2. Calling search_near for a value beyond the end
cursor.set_key(self.genkey(self.nentries))
diff --git a/test/suite/test_cursor05.py b/test/suite/test_cursor05.py
index 2034e6ccd50..9410c75b0e3 100644
--- a/test/suite/test_cursor05.py
+++ b/test/suite/test_cursor05.py
@@ -31,10 +31,7 @@
# Mix that in with column groups.
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
+import wiredtiger, wttest
class test_cursor05(wttest.WiredTigerTestCase):
"""
diff --git a/test/suite/test_cursor_tracker.py b/test/suite/test_cursor_tracker.py
index 9f77bc76a93..4bd3b787c61 100644
--- a/test/suite/test_cursor_tracker.py
+++ b/test/suite/test_cursor_tracker.py
@@ -72,11 +72,8 @@
# (though simulating transactions would probably be beyond what
# we want to do here).
-import unittest
import hashlib
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
+import wiredtiger, wttest
class TestCursorTracker(wttest.WiredTigerTestCase):
table_name1 = 'test_cursor'
@@ -420,10 +417,10 @@ class TestCursorTracker(wttest.WiredTigerTestCase):
raise Exception('cur_check_here: cursor.get_key, get_value are not valid')
elif self.nopos:
self.traceapi_before('cursor.get_key()')
- self.assertRaises(WiredTigerError, cursor.get_key)
+ self.assertRaises(wiredtiger.WiredTigerError, cursor.get_key)
self.traceapi_after('<unknown>')
self.traceapi_before('cursor.get_value()')
- self.assertRaises(WiredTigerError, cursor.get_value)
+ self.assertRaises(wiredtiger.WiredTigerError, cursor.get_value)
self.traceapi_after('<unknown>')
else:
bits = self.curbits
diff --git a/test/suite/test_drop_create.py b/test/suite/test_drop_create.py
index 61f53380192..79f5d325ef0 100644
--- a/test/suite/test_drop_create.py
+++ b/test/suite/test_drop_create.py
@@ -25,14 +25,11 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
-# test_base03.py
-# Cursor operations
+# test_drop_create.py
+# Test dropping and creating
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
+import wiredtiger, wttest
class test_drop_create(wttest.WiredTigerTestCase):
def test_drop_create(self):
diff --git a/test/suite/test_index01.py b/test/suite/test_index01.py
index ff2530c213e..b807a5e4e6c 100644
--- a/test/suite/test_index01.py
+++ b/test/suite/test_index01.py
@@ -29,10 +29,7 @@
# basic tests for indices
#
-import unittest
-import wiredtiger
-from wiredtiger import WT_NOTFOUND
-import wttest
+import wiredtiger, wttest
class test_index01(wttest.WiredTigerTestCase):
'''Test basic operations for indices'''
@@ -117,7 +114,7 @@ class test_index01(wttest.WiredTigerTestCase):
cursor = self.cursor()
cursor.set_key(*cols[:2]);
cursor.set_value(*cols[2:])
- self.assertEqual(cursor.update(), WT_NOTFOUND)
+ self.assertEqual(cursor.update(), wiredtiger.WT_NOTFOUND)
cursor.close()
def remove(self, name, ID):
@@ -130,7 +127,7 @@ class test_index01(wttest.WiredTigerTestCase):
def test_empty(self):
'''Create a table, look for a nonexistent key'''
self.create_table()
- self.check_exists('jones', 10, WT_NOTFOUND)
+ self.check_exists('jones', 10, wiredtiger.WT_NOTFOUND)
for i in xrange(self.NUM_INDICES):
self.assertEqual(list(self.index_iter(i)), [])
self.drop_table()
@@ -212,7 +209,7 @@ class test_index01(wttest.WiredTigerTestCase):
self.insert('smith', 1, 'HR', 'manager', 100000, 1970)
self.check_exists('smith', 1, 0)
self.remove('smith', 1)
- self.check_exists('smith', 1, WT_NOTFOUND)
+ self.check_exists('smith', 1, wiredtiger.WT_NOTFOUND)
for i in xrange(self.NUM_INDICES):
self.assertEqual(list(self.index_iter(i)), [])
self.drop_table()
diff --git a/test/suite/test_priv01.py b/test/suite/test_priv01.py
index 68e6fa0b0c2..bc27df58621 100644
--- a/test/suite/test_priv01.py
+++ b/test/suite/test_priv01.py
@@ -32,11 +32,8 @@
# (e.g. root) user, and should pass in both cases.
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
import os
+import wiredtiger, wttest
class test_priv01(wttest.WiredTigerTestCase):
"""
@@ -169,7 +166,7 @@ class test_priv01(wttest.WiredTigerTestCase):
self.checkfiles(edir)
self.checknofiles(".")
else:
- self.assertRaises(WiredTigerError,
+ self.assertRaises(wiredtiger.WiredTigerError,
lambda: self.common_test(None, edir, privarg))
def test_env_conf_without_env_var_priv(self):
diff --git a/test/suite/test_schema01.py b/test/suite/test_schema01.py
index 4e7a22dc5d1..c052221ebf6 100644
--- a/test/suite/test_schema01.py
+++ b/test/suite/test_schema01.py
@@ -29,10 +29,7 @@
# Test that tables are reconciled correctly when they are empty.
#
-import unittest
-import wiredtiger
-from wiredtiger import WT_NOTFOUND
-import wttest
+import wiredtiger, wttest
pop_data = [
( 'USA', 1980, 226542250 ),
diff --git a/test/suite/test_schema02.py b/test/suite/test_schema02.py
index 259c4d5a9f1..0cfe8592f1f 100644
--- a/test/suite/test_schema02.py
+++ b/test/suite/test_schema02.py
@@ -29,10 +29,7 @@
# Columns, column groups, indexes
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
+import wiredtiger, wttest
class test_schema02(wttest.WiredTigerTestCase):
"""
@@ -41,11 +38,11 @@ class test_schema02(wttest.WiredTigerTestCase):
nentries = 1000
def expect_failure_primary(self, configstr):
- self.assertRaises(WiredTigerError,
+ self.assertRaises(wiredtiger.WiredTigerError,
lambda:self.session.create("table:main", configstr))
def expect_failure_colgroup(self, name, configstr):
- self.assertRaises(WiredTigerError,
+ self.assertRaises(wiredtiger.WiredTigerError,
lambda:self.session.create("colgroup:" + name, configstr))
def test_colgroup_after_failure(self):
diff --git a/test/suite/test_schema03.py b/test/suite/test_schema03.py
index cf864a2a347..2a39c8383ce 100644
--- a/test/suite/test_schema03.py
+++ b/test/suite/test_schema03.py
@@ -31,13 +31,9 @@
# modified values for SHOW_PYTHON* variables.
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
-import wtscenario
-import suite_random
import resource
+import suite_random
+import wiredtiger, wtscenario, wttest
def extract_random_from_list(rand, list):
pos = rand.rand_range(0, len(list))
diff --git a/test/suite/test_stat01.py b/test/suite/test_stat01.py
index 008cfb2d4ac..c4aced15592 100644
--- a/test/suite/test_stat01.py
+++ b/test/suite/test_stat01.py
@@ -29,10 +29,7 @@
# Statistics operations
#
-import unittest
-import wiredtiger
-import wttest
-import test_base03
+import wiredtiger, wttest
class test_stat01(wttest.WiredTigerTestCase):
"""
diff --git a/test/suite/test_util01.py b/test/suite/test_util01.py
index 6c1886def71..5523d756cc8 100644
--- a/test/suite/test_util01.py
+++ b/test/suite/test_util01.py
@@ -29,12 +29,9 @@
# Utilities: wt dump, as well as the dump cursor
#
-import unittest
-import wiredtiger
-import wttest
+import string, os
from suite_subprocess import suite_subprocess
-import os
-import string
+import wiredtiger, wttest
class test_util01(wttest.WiredTigerTestCase, suite_subprocess):
"""
diff --git a/test/suite/test_util02.py b/test/suite/test_util02.py
index 685c5d75179..b3a75441064 100644
--- a/test/suite/test_util02.py
+++ b/test/suite/test_util02.py
@@ -29,12 +29,9 @@
# Utilities: wt load
#
-import unittest
-import wiredtiger
-import wttest
+import string, os
from suite_subprocess import suite_subprocess
-import os
-import string
+import wiredtiger, wttest
class test_util02(wttest.WiredTigerTestCase, suite_subprocess):
"""
diff --git a/test/suite/test_util03.py b/test/suite/test_util03.py
index 1667ca89d62..7baf2d47b29 100644
--- a/test/suite/test_util03.py
+++ b/test/suite/test_util03.py
@@ -29,10 +29,8 @@
# Utilities: wt create
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
from suite_subprocess import suite_subprocess
+import wiredtiger, wttest
class test_util03(wttest.WiredTigerTestCase, suite_subprocess):
tablename = 'test_util03.a'
diff --git a/test/suite/test_util04.py b/test/suite/test_util04.py
index 196955e8d59..6b191d11fc4 100644
--- a/test/suite/test_util04.py
+++ b/test/suite/test_util04.py
@@ -29,11 +29,9 @@
# Utilities: wt drop
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
-from suite_subprocess import suite_subprocess
import os
+from suite_subprocess import suite_subprocess
+import wiredtiger, wttest
class test_util04(wttest.WiredTigerTestCase, suite_subprocess):
tablename = 'test_util04.a'
@@ -50,7 +48,8 @@ class test_util04(wttest.WiredTigerTestCase, suite_subprocess):
self.runWt(["drop", "table:" + self.tablename])
self.assertFalse(os.path.exists(self.tablename + ".wt"))
- self.assertRaises(WiredTigerError, lambda: self.session.open_cursor('table:' + self.tablename, None, None))
+ self.assertRaises(wiredtiger.WiredTigerError,
+ lambda: self.session.open_cursor('table:' + self.tablename, None, None))
if __name__ == '__main__':
diff --git a/test/suite/test_util05.py b/test/suite/test_util05.py
index 336c54d18b0..12b0a851515 100644
--- a/test/suite/test_util05.py
+++ b/test/suite/test_util05.py
@@ -29,12 +29,9 @@
# Utilities: wt verify
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
+import os, struct
from suite_subprocess import suite_subprocess
-import os
-import struct
+import wiredtiger, wttest
class test_util05(wttest.WiredTigerTestCase, suite_subprocess):
tablename = 'test_util05.a'
@@ -143,7 +140,8 @@ class test_util05(wttest.WiredTigerTestCase, suite_subprocess):
# open_and_position closed the session/connection, reopen them now.
self.conn = self.setUpConnectionOpen(".")
self.session = self.setUpSessionOpen(self.conn)
- self.assertRaises(WiredTigerError, lambda: self.session.verify('table:' + self.tablename, None))
+ self.assertRaises(wiredtiger.WiredTigerError,
+ lambda: self.session.verify('table:' + self.tablename, None))
def test_verify_process_75pct_null(self):
"""
diff --git a/test/suite/test_util06.py b/test/suite/test_util06.py
index 511e436f7e6..67be749ff87 100644
--- a/test/suite/test_util06.py
+++ b/test/suite/test_util06.py
@@ -29,12 +29,9 @@
# Utilities: wt salvage
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
+import os, struct
from suite_subprocess import suite_subprocess
-import os
-import struct
+import wiredtiger, wttest
class test_util06(wttest.WiredTigerTestCase, suite_subprocess):
tablename = 'test_util06.a'
@@ -204,7 +201,8 @@ class test_util06(wttest.WiredTigerTestCase, suite_subprocess):
# damage() closed the session/connection, reopen them now.
self.open_conn()
- self.assertRaises(WiredTigerError, lambda: self.session.verify('table:' + self.tablename, None))
+ self.assertRaises(wiredtiger.WiredTigerError,
+ lambda: self.session.verify('table:' + self.tablename, None))
self.session.salvage('file:' + self.tablename + ".wt", None)
self.check_damaged(self.tablename)
diff --git a/test/suite/test_util07.py b/test/suite/test_util07.py
index 5d5467ba1cc..5865977d6f2 100644
--- a/test/suite/test_util07.py
+++ b/test/suite/test_util07.py
@@ -29,12 +29,9 @@
# Utilities: wt read
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
+import os, struct
from suite_subprocess import suite_subprocess
-import os
-import struct
+import wiredtiger, wttest
class test_util07(wttest.WiredTigerTestCase, suite_subprocess):
tablename = 'test_util07.a'
diff --git a/test/suite/test_util08.py b/test/suite/test_util08.py
index 4c1ebc4eeb2..9d460cd8560 100644
--- a/test/suite/test_util08.py
+++ b/test/suite/test_util08.py
@@ -29,10 +29,8 @@
# Utilities: wt copyright
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
from suite_subprocess import suite_subprocess
+import wiredtiger, wttest
class test_util08(wttest.WiredTigerTestCase, suite_subprocess):
def test_copyright(self):
diff --git a/test/suite/test_util09.py b/test/suite/test_util09.py
index f0d4aadc893..cdcc7fd38df 100644
--- a/test/suite/test_util09.py
+++ b/test/suite/test_util09.py
@@ -29,12 +29,9 @@
# Utilities: wt loadtext
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
+import os, struct
from suite_subprocess import suite_subprocess
-import os
-import struct
+import wiredtiger, wttest
class test_util09(wttest.WiredTigerTestCase, suite_subprocess):
tablename = 'test_util09.a'
diff --git a/test/suite/test_util10.py b/test/suite/test_util10.py
index e79ab09476a..faaefdef005 100644
--- a/test/suite/test_util10.py
+++ b/test/suite/test_util10.py
@@ -29,12 +29,9 @@
# Utilities: wt dumpfile
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
+import os, struct
from suite_subprocess import suite_subprocess
-import os
-import struct
+import wiredtiger, wttest
class test_util10(wttest.WiredTigerTestCase, suite_subprocess):
tablename = 'test_util10.a'
diff --git a/test/suite/test_util11.py b/test/suite/test_util11.py
index d5b9fb3f9c2..e7ba1358e32 100644
--- a/test/suite/test_util11.py
+++ b/test/suite/test_util11.py
@@ -29,12 +29,9 @@
# Utilities: wt list
#
-import unittest
-from wiredtiger import WiredTigerError
-import wttest
+import os, struct
from suite_subprocess import suite_subprocess
-import os
-import struct
+import wiredtiger, wttest
class test_util11(wttest.WiredTigerTestCase, suite_subprocess):
tablenamepfx = 'test_util11.'
diff --git a/test/suite/test_util12.py b/test/suite/test_util12.py
index 20f8270ffe9..b527dd16f85 100644
--- a/test/suite/test_util12.py
+++ b/test/suite/test_util12.py
@@ -29,13 +29,9 @@
# Utilities: wt write
#
-import unittest
-import wiredtiger
-from wiredtiger import WiredTigerError
-import wttest
+import os, struct
from suite_subprocess import suite_subprocess
-import os
-import struct
+import wiredtiger, wttest
class test_util12(wttest.WiredTigerTestCase, suite_subprocess):
tablename = 'test_util12.a'
diff --git a/test/suite/wttest.py b/test/suite/wttest.py
index 1c5f0dabc11..7084289609a 100644
--- a/test/suite/wttest.py
+++ b/test/suite/wttest.py
@@ -29,12 +29,14 @@
# parent class for all test cases
#
-import unittest
-import sys
-import os
+# If unittest2 is available, use it in preference to (the old) unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+import sys, time, traceback, os
import wiredtiger
-import traceback
-import time
def removeAll(top):
if not os.path.isdir(top):