Search code examples
pythonnosepeewee

Python: Conditional variables based on whether nosetest is running


I'm running nosetests which have a setup function that needs to load a different database than the production database. The ORM I'm using is peewee which requires that the database for a model is set in the definition.

So I need to set a conditional variable but I don't know what condition to use in order to check if nosetest is running the file.

I read on Stack Overflow that you can check for nose in sys.modules but I was wondering if there is a more exact way to check if nose is running.


Solution

  • Perhaps examining sys.argv[0] to see what command is running?