could nosetest just has erased my DB? and some other tg/ nosetests related question

31 views
Skip to first unread message

alonn

unread,
Jan 15, 2013, 7:46:48 PM1/15/13
to turbo...@googlegroups.com
I decided to start learning how to do proper unittesting and using nosetests. and I have some questions after encountering some very annoying problems.
1. state configuration: I've noticed when I'm not running nosetests from the main project directory everything that depends on app state (such as information from the ini file) fails.  is this observation true? can I run nosetests with app state also for a specific test file without the whole testing suite? 

2. app state and configuration: what ini file does nosetest refer to? development.in, production.ini? other?

3. I'm using a 2 db configuration: the app inner setting are in a mysql/sqlite db and it works also with a mssql server (I have write permissions, but this the DB of another app = I can't temper with the tables no matter what), also the sqlalchemy in the app works with the dual-db configuration (after a short battle) the tests do not. I need the db not to be erased after the testing  (which just happened to me, fortunately enpugh. and by mistake,  only in the app inner db and not in the main mssql db)


be glad with any help with thi

Moritz Schlarb

unread,
Jan 16, 2013, 5:05:28 AM1/16/13
to turbo...@googlegroups.com
The test suite should be using test.ini (which inherits from development.ini).
Maybe you take a look at the responsive files in a fresh quickstart!

Due to your two-database setup, you surely need to use other sqlalchemy.url lines in the test.ini, I suspect that your application uses different config variable names and therefore just got the inherited values from development.ini.

For testing, an sqlite database in memory is used because it is very much faster than a real db (and furthermore, the test suite should be independent of any infrastructure).

alonn

unread,
Jan 16, 2013, 7:36:30 AM1/16/13
to turbo...@googlegroups.com
Thanks Moritz. I found and inspected test.ini and found this line:
    
    use = config:development.ini

If I understand correctly this means: take the configuration from development.ini.  would the information from development.ini replace the same variables in test.ini? And I should I remove this line when I populate test.ini with test configuration. or does it only add data not specified in test.ini

Moritz Schlarb

unread,
Jan 16, 2013, 9:43:03 AM1/16/13
to turbo...@googlegroups.com
You should not replace that import line, I think!

But when you use multiple database like this: http://turbogears.org/2.1/docs/main/MultipleDatabases.html, you should of course use something like
sqlalchemy.first.url = sqlite:///:memory:
sqlalchemy.second.url = sqlite:///:memory:

And I think it might be good to include that note about the test suite on that page, too!

alonn

unread,
Jan 16, 2013, 11:36:16 AM1/16/13
to turbo...@googlegroups.com
could someone please shed more light about this issue? how can I override some of development.ini imports (without loosing all of them)

Moritz Schlarb

unread,
Jan 16, 2013, 12:27:15 PM1/16/13
to turbo...@googlegroups.com
Just look at how it's done already for sqlalchemy.url?!

Michael Pedersen

unread,
Feb 10, 2013, 3:17:55 PM2/10/13
to tg-trunk
Check out http://pythonpaste.org/deploy/#config-uris as there is a *huge* amount of information there about the way that "use = config:' works.


--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To view this discussion on the web visit https://groups.google.com/d/msg/turbogears/-/k6yqMfPHAxEJ.

To post to this group, send email to turbo...@googlegroups.com.
To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.



--
Michael J. Pedersen
My Online Resume: http://www.icelus.org/ -- Google+ http://plus.ly/pedersen
Google Talk: m.ped...@icelus.org -- Twitter: pedersentg

alonn

unread,
Feb 11, 2013, 7:41:25 AM2/11/13
to turbo...@googlegroups.com
Thanks!
Reply all
Reply to author
Forward
0 new messages