Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1177 (closed enhancement: fixed)

Opened 12 years ago

Last modified 11 years ago

[PATCH] Allow configuration of unit tests via test.cfg

Reported by: timfreund Owned by: anonymous
Priority: normal Milestone:
Component: unassigned Version: 1.0b1
Severity: normal Keywords:
Cc:

Description

I just started writing unit tests for my application, and I ran into two issues that made support for a test.cfg file desirable.

  • I want to switch between testing with SQLite in memory and PostgreSQL
  • Some configuration properties in app.cfg need to be present for my tests to succeed.

This patch checks for the presence of test.cfg. If test.cfg exists, the following things happen:

  • The module where app.cfg lives is discerned based on the current working directory. This assumes that the tests are run from the root of the application directory. (room for improvement)
  • update_config is called, loading test.cfg and app.cfg

If no test.cfg exists, the default database uri of sqlite:///:memory: is used.

Additionally, cherrypy is not started immediately in testutil.py. It is started only when the first test case is run. Calling cherrypy.server.start right away in an identity enabled application causes a problem because cherrypy.root is not yet set:

AttributeError?: 'NoneType?' object has no attribute '_cp_filters'

Attachments

testutil.patch Download (1.8 KB) - added by timfreund 12 years ago.

Change History

Changed 12 years ago by timfreund

comment:1 Changed 12 years ago by alberto

+1 from me for applying this patch. I find the functionality very useful as I personally do something similar to setup the database in some projects which rely on stored procedures and triggers in the DB. Having this functionality built into TG would be nice IMO :)

Haven't tested it yet though... can anyone else give some feedback?

Alberto

comment:2 Changed 12 years ago by alberto

  • Status changed from new to closed
  • Resolution set to fixed

Comitted at [2263]. Thanks :)

Note: See TracTickets for help on using tickets.