[Zope-Checkins] CVS: Products/DCOracle2/test - common.py:1.8
Chris Withers
cvs-admin at zope.org
Thu Oct 30 11:49:04 EST 2003
Update of /cvs-repository/Products/DCOracle2/test
In directory cvs.zope.org:/tmp/cvs-serv2814
Modified Files:
common.py
Log Message:
new fixtures to help with tests.
=== Products/DCOracle2/test/common.py 1.7 => 1.8 ===
--- Products/DCOracle2/test/common.py:1.7 Fri Oct 24 06:50:03 2003
+++ Products/DCOracle2/test/common.py Thu Oct 30 11:49:03 2003
@@ -1,6 +1,7 @@
-#
-
+import DCOracle2
import os
+import random
+import unittest
connstrings = {
"bane": "scott/tiger",
@@ -27,3 +28,49 @@
raise KeyError,"Please specify connection string for tests in "\
"DCORACLE_TEST_CONNSTRING environment variable"
+
+class TestCase(unittest.TestCase):
+
+ tables_to_drop = ()
+
+ def setUp(self):
+
+ self.db = db = DCOracle2.connect(getConnectionString())
+ self.c = c = db.cursor()
+
+ for tablename in self.tables_to_drop:
+ try:
+ c.execute('drop table '+tablename)
+ except DCOracle2.DatabaseError:
+ pass
+
+ username,password,dbname = self._getConnDetails()
+ self.username = username.upper()
+
+ def tearDown(self):
+
+ self.c.close()
+
+ def _getBinary(self,kb):
+
+ return ''.join([
+ chr(random.randint(0,255))
+ for x
+ in range(kb*1000)
+ ])
+
+ def _getConnDetails(self):
+ dsn = getConnectionString()
+ try:
+ userpass, dbname = dsn.split("@")
+ except ValueError:
+ userpass = dsn
+ dbname = ""
+
+ try:
+ username, password = userpass.split("/")
+ except ValueError:
+ username = dsn
+ password = ""
+
+ return username,password,dbname
More information about the Zope-Checkins
mailing list