[z3-checkins] r18246 -
z3/sqlos/branch/jinty-3.0-fix_the_tests/transaction
jinty at codespeak.net
jinty at codespeak.net
Fri Oct 7 09:32:14 CEST 2005
Author: jinty
Date: Fri Oct 7 09:32:13 2005
New Revision: 18246
Modified:
z3/sqlos/branch/jinty-3.0-fix_the_tests/transaction/__init__.py
Log:
Get the transaction tests to create disposable test database rather than using the same one every time. (124)
Modified: z3/sqlos/branch/jinty-3.0-fix_the_tests/transaction/__init__.py
==============================================================================
--- z3/sqlos/branch/jinty-3.0-fix_the_tests/transaction/__init__.py (original)
+++ z3/sqlos/branch/jinty-3.0-fix_the_tests/transaction/__init__.py Fri Oct 7 09:32:13 2005
@@ -40,6 +40,13 @@
>>> from zope.app.tests.placelesssetup import setUp, tearDown
>>> setUp()
+ Make a testing db:
+
+ >>> import tempfile
+ >>> import urllib
+ >>> fh, testdb_file = tempfile.mkstemp()
+ >>> testdb_url = 'sqlite://' + urllib.pathname2url(testdb_file)
+
First, register the subscribers:
>>> from zope.app.tests import ztapi
@@ -59,7 +66,7 @@
>>> from sqlobject.dbconnection import connectionForURI
>>> from sqlos.tests.sampleperson import SamplePerson
>>> from sqlos.adapter import SQLiteAdapter
- >>> connection = connectionForURI('sqlite:///tmp/sqlite.db')
+ >>> connection = connectionForURI(testdb_url)
>>> adapter = SQLiteAdapter(connection.makeConnection())
Stuff the connection into the test class and initialize the table
@@ -183,8 +190,10 @@
>>> SamplePerson.expire = oldexpire
>>> del SamplePerson._expire_called
- And finally call tearDown to cleanup the environment:
+ And finally call tearDown and cleanup:
+ >>> import os
+ >>> os.remove(testdb_file)
>>> tearDown()
"""
More information about the z3-checkins
mailing list