#2404: Model initialisation fails while running functional tests
------------------------+---------------------------------------------------
Reporter: goodgravy | Owner:
Type: defect | Status: new
Priority: normal | Milestone: __unclassified__
Component: TurboGears | Version: 2.0.3
Severity: major | Resolution:
Keywords: |
------------------------+---------------------------------------------------
Comment (by goodgravy):
Cause of the problem is that different SQLAlchemy engines are being used
during the set-up and run phases of my second test.
Advice from the SQLAlchemy list was that there should only ever be one
engine (i.e. one call to `create_engine`). However, I assume that the
multiple calls TG2 makes is symptomatic of wanting a completely blank
slate for each test method.
While running the second test in a suite, a new engine is created and used
for the DDL statements results from `model.metadata.create_all`, but the
original engine from the ''first'' test is used by the ORM during the
actual test.
Invoking `DBSession.configure(bind=my_new_engine)` does not seem to update
the engine in use by the
ORM.
There seems to be two possible fixes:
1. get SQLAlchemy to realise we've moved on to a new engine
1. only use one engine throughout an entire TG2 test suite, as SQLAlchemy
currently expects
I've created a github project here: http://github.com/goodgravy/tg2-broken
which recreates the bug. It's a new TG2 application, with the one new
controller method (in `root.py`) and two new tests (in `test_root.py`).
--
Ticket URL: <http://trac.turbogears.org/ticket/2404#comment:2>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---