functional tests in tg2

3 views
Skip to first unread message

Alessandro Molina

unread,
Oct 22, 2009, 9:09:23 AM10/22/09
to turbo...@googlegroups.com
Hi,
I'm actually trying to write functional tests for a complex web application.

I'm unable to write tests as they don't setup correctly the model.
I have a websetup.py that creates the schema by calling
model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine) and
then checks if some groups in tg_group already exist, if they don't it creates
them.

When I call paster setup-app development.ini everything works as expected

When the test suite calls websetup.py from TestController.setUp the
websetup.py fails when checking for the existing groups saying that
"(OperationalError) no such table: tg_group" even if the line before was the
metadata.create_all call.

My test.ini has the default configuration.
I think that I'm missing something, but I'm unable to find some extensive doc
about tests in TG2.

Alessandro Molina

unread,
Oct 22, 2009, 9:13:14 AM10/22/09
to turbo...@googlegroups.com
On Thursday 22 October 2009 15:09:23 Alessandro Molina wrote:
> When the test suite calls websetup.py from TestController.setUp the
> websetup.py fails when checking for the existing groups saying that
> "(OperationalError) no such table: tg_group" even if the line before was
> the metadata.create_all call.

I also have to say that if I change

sqlalchemy.url = sqlite:///:memory:

to

sqlalchemy.url = sqlite:///foobar.db

in test.ini
everything works as expected. But I should be able to make tests work also on
memory db

James

unread,
Nov 5, 2009, 4:14:01 PM11/5/09
to TurboGears
I'm seeing similar behaviour: I have two test methods in a class. Each
method completes successfully when run in isolation, but when I run
them both as a suite, I get "no such table" exceptions.

In the same way as the OP, the suite passes as expected when I use a
sqlite file database, rather than in-memory.

Does anyone have any ideas? I don't seem to be doing anything
particularly odd in websetup.py or setUp methods...

Thanks!
James

On Oct 22, 1:13 pm, Alessandro Molina <alessandro.mol...@gmail.com>
wrote:
> On Thursday 22 October 2009 15:09:23 Alessandro Molina wrote:
>
> > When thetestsuite calls websetup.py from TestController.setUp the
> > websetup.py fails when checking for the existing groups saying that
> > "(OperationalError)no such table: tg_group" even if the line before was
Reply all
Reply to author
Forward
0 new messages