[SQL-CVS] r779 - in trunk/SQLObject/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2005-05-10 17:02:44
|
Author: ianb
Date: 2005-05-10 17:02:35 +0000 (Tue, 10 May 2005)
New Revision: 779
Added:
trunk/SQLObject/sqlobject/conftest.py
Modified:
trunk/SQLObject/sqlobject/tests/dbtest.py
Log:
Use py.test conftest file to add a --Database option (instead of postgres)... more customization upcoming
Added: trunk/SQLObject/sqlobject/conftest.py
===================================================================
--- trunk/SQLObject/sqlobject/conftest.py 2005-05-07 05:54:12 UTC (rev 778)
+++ trunk/SQLObject/sqlobject/conftest.py 2005-05-10 17:02:35 UTC (rev 779)
@@ -0,0 +1,31 @@
+"""
+This module is used by py.test to configure testing for this
+application.
+"""
+
+# Override some options (doesn't override command line):
+verbose = 0
+exitfirst = True
+
+import py
+import os
+
+connectionShortcuts = {
+ 'mysql': 'mysql://test@localhost/test',
+ 'dbm': 'dbm:///data',
+ 'postgres': 'postgres:///test',
+ 'postgresql': 'postgres:///test',
+ 'pygresql': 'pygresql://localhost/test',
+ 'sqlite': 'sqlite:///%s/data/sqlite.data' % os.getcwd(),
+ 'sybase': 'sybase://test:test123@sybase/test?autoCommit=0',
+ 'firebird': 'firebird://sysdba:masterkey@localhost/var/lib/firebird/data/test.gdb',
+ }
+
+Option = py.test.Config.Option
+option = py.test.Config.addoptions(
+ "SQLObject options",
+ Option('-D', '--Database',
+ action="store", dest="Database", default='sqlite',
+ help="The database to run the tests under (default sqlite). "
+ "Can also use an alias from: %s"
+ % (', '.join(connectionShortcuts.keys()))))
Modified: trunk/SQLObject/sqlobject/tests/dbtest.py
===================================================================
--- trunk/SQLObject/sqlobject/tests/dbtest.py 2005-05-07 05:54:12 UTC (rev 778)
+++ trunk/SQLObject/sqlobject/tests/dbtest.py 2005-05-10 17:02:35 UTC (rev 779)
@@ -5,8 +5,10 @@
import sys
import os
import re
-import sqlobject
from py.test import raises
+import py
+import sqlobject
+import sqlobject.conftest as conftest
if sys.platform[:3] == "win":
def getcwd():
@@ -14,17 +16,6 @@
else:
getcwd = os.getcwd
-connectionShortcuts = {
- 'mysql': 'mysql://test@localhost/test',
- 'dbm': 'dbm:///data',
- 'postgres': 'postgres:///test',
- 'postgresql': 'postgres:///test',
- 'pygresql': 'pygresql://localhost/test',
- 'sqlite': 'sqlite:///%s/data/sqlite.data' % getcwd(),
- 'sybase': 'sybase://test:test123@sybase/test?autoCommit=0',
- 'firebird': 'firebird://sysdba:masterkey@localhost/var/lib/firebird/data/test.gdb',
- }
-
"""
supportsMatrix defines what database backends support what features.
Each feature has a name, if you see a key like '+featureName' then
@@ -86,17 +77,16 @@
'sqlite:///' + installedDBFilename)
def getConnection(**kw):
- name = os.environ.get('TESTDB')
- assert name, 'You must set $TESTDB to do database operations'
- if connectionShortcuts.has_key(name):
- name = connectionShortcuts[name]
+ name = conftest.option.Database
+ if conftest.connectionShortcuts.has_key(name):
+ name = conftest.connectionShortcuts[name]
return sqlobject.connectionForURI(name, **kw)
connection = getConnection()
class InstalledTestDatabase(sqlobject.SQLObject):
"""
- This table is set up in SQLite (always, regardless of $TESTDB) and
+ This table is set up in SQLite (always, regardless of --Database) and
tracks what tables have been set up in the 'real' database. This
way we don't keep recreating the tables over and over when there
are multiple tests that use a table.
|