TG2 app testing troubles

0 views
Skip to first unread message

Diez B. Roggisch

unread,
Jul 9, 2008, 6:49:40 AM7/9/08
to TurboGears Trunk
Hi,

after grasping that the pylons-docs are a good way to understand how to deal
with TG2, I took a look at the unit-testing for my planned authentication
wrapping.

Now a problem seems to be that nosetests don't find the *.ini properly, and
that the generate controller_test is hard-coded to use development.ini
instead of test.ini.

So I had to change

config
= 'config:'+(os.path.abspath(os.path.basename(__name__)+'/../../development.ini#main'))

to

config
= 'config:'+(os.path.abspath(os.path.basename(__name__)+'/../../test.ini#main'))

in tests/test_controllers.

I also have to run the tests doing

nosetests -sw tests/

otherwise nose complains with

ERROR: Failure: OSError (File '/home/dir/projects/ableton/Web/test.ini' not
found)

which seems to stem from nose not setting the CWD as expected by the above
code. A solution would be to look from CWD upwards to where the test.ini is
found (if any...) instead of hard-coding the ../../

So - shall I create a ticket for this? And possibly even a patch?

Generally, what about DB-tests? I helped myself doing

class TestTGController:
def test_index(self):
import authenticationtest.model
m = authenticationtest.model
m.metadata.create_all()


(code that obviously will need to go into setUp, I'm just in the middle of
working my way through this)

but shouldn't we supply some base-class that does that?

Diez

Mark Ramm

unread,
Jul 9, 2008, 11:34:40 AM7/9/08
to turbogea...@googlegroups.com
Yea, make a ticket for this, and patches always appreciated. ;)

I think there was a desire to port the work that was done on creating
a WebTest based testutil module for 1.5 to tg2, and now that the 1.5
testing story is finished, we should look at this much more closely.

--Mark

--
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

percious

unread,
Jul 14, 2008, 4:24:51 PM7/14/08
to TurboGears Trunk
Diez,

I would simply copy your development.ini to test.ini and not skip a
beat. This "feature" is not likely to be removed, because I can
imagine a scenario where a developer would like a different ini file
for unit testing than that of development.

As far as database tests are concerned, take a look at:
http://pythontutorials.googlecode.com/svn/tutorials/barbershop/ In
that project I set up a test framework which shows how to use sqlite
to test the database.

cheers.
-chris

Diez B. Roggisch

unread,
Jul 15, 2008, 2:23:34 PM7/15/08
to turbogea...@googlegroups.com
percious schrieb:

> Diez,
>
> I would simply copy your development.ini to test.ini and not skip a
> beat. This "feature" is not likely to be removed, because I can
> imagine a scenario where a developer would like a different ini file
> for unit testing than that of development.

I think you might have misunderstood. The problem is that the freshly
generated tests

- look for development.ini instead of test.ini

- don't find it unless told in a rather special way

> As far as database tests are concerned, take a look at:
> http://pythontutorials.googlecode.com/svn/tutorials/barbershop/ In
> that project I set up a test framework which shows how to use sqlite
> to test the database.

Will do, thanks. Still this needs to become part of TG2 I think.

Diez

Reply all
Reply to author
Forward
0 new messages