CleanCut / green

Green is a clean, colorful, fast python test runner.
MIT License
791 stars 75 forks source link

Run 1 process by default? #109

Closed rudyryk closed 8 years ago

rudyryk commented 8 years ago

I've just faced a really weird issue.

I got a basic test suite within web project with database. I'm testing creating, inserting, deleting database objects. From time to time I got "unique constraint" error. That was really strange and I spent a couple hours to find out what's happening.

As I understand that was because of multiple processes running and trying to insert objects from different tests! I didn't expect it at all. I expected my tests just run sequentially on clean database (I clean it up in setUp method).

And I believe that is very common use case.

CleanCut commented 8 years ago

(Sorry for the long delay -- I've been in crunch time for months)

One of the main reasons for green to exist is to be a fast test runner. Running in multiple processes is part of that. If that means some people are turned off and don't want to use it because their existing tests can't be safely run concurrently, I'm okay with that.

If you personally want to use green and have it default to 1 process, you can create a config file (either $HOME/.green or export an environment variable GREEN_CONFIG which points to some other location) and put this in it:

processes = 1

...or of course you could make your own fork (or just alter your local module on-disk) and change the default on line 46 of green/config.py to 1 ;-)