Pylons: Testing Configuration

June 7, 2009 § Leave a comment

It’s nice that Pylons include nosetest and TestUnit as part of its testing framework.

Unfortunately, using those for unit testing inside Pylons is not trivial, not obvious, and inconvenient.

For examples:

  • I can only run nosetests on top-level directory because config is expecting ‘test.ini’ file. That’s inconvenient.
  • It is not obvious how build sqlalchemy’s engine inside tests/__init__.py. Ideally, I can build the engine based on test.ini configurations.

To answer those questions, this is how my __init__.py looks like:

The __init__ file solves various problems:

  • I can run nosetests anywhere inside project’s directory tree.
  • With simple convention, __init__ will look for test.ini file on top-level directory.
  • SqlAlchemy engine is built using configuration set in test.ini

I hope this snippet can help readers in getting up to speed in Pylons even quicker.

Advertisements

Tagged:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

What’s this?

You are currently reading Pylons: Testing Configuration at RAPD.

meta

%d bloggers like this: