Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40422

How to prevent tests from running against production?

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject How to prevent tests from running against production?
Date 2013-03-03 16:56 -0500
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-A05619.16561603032013@news.panix.com> (permalink)

Show all headers | View raw


Our deploy/configuration system includes credentials for connecting to a 
database.  We have one production database, and a variety of clones of 
that in our test and development environments.

We've got a large body of tests, written with a combination of unittest 
and nose.  Many of our tests do things which shouldn't be done against 
the production database.  I'd like to set things up so anytime any test 
code gets run, a check is made to see which database you're connected to 
and if you're connect to production, the test refuses to run.

It's easy to write a check like that in setup(), but that only gets 
called if you remember to write a setup() method (or inherit from 
something that does).  I'm looking for something that runs completely 
automatically.  I don't want somebody to be able to write something 
which causes damage that nose can discover and run when you're connected 
to the wrong database.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

How to prevent tests from running against production? Roy Smith <roy@panix.com> - 2013-03-03 16:56 -0500
  Re: How to prevent tests from running against production? Ross Ridge <rridge@csclub.uwaterloo.ca> - 2013-03-03 23:30 -0500
  Re: How to prevent tests from running against production? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-04 07:05 +0000

csiph-web