Coverage a file with python -bb (bytes_warning=2)

100 Views Asked by At

I use coverage to run tests and I would like to issue errors about str(bytes_instance), str(bytearray_instance) and comparing bytes/bytearray with str. (i.e. running python -bb). Is there a way to run coverage like this or to activate bytes_warning progamatically?

1

There are 1 best solutions below

3
On BEST ANSWER

Interesting, I had never seen -bb before, and it's too bad Python doesn't provide an environment variable that also controls it.

You can run coverage as a module, which lets you access the Python command line you want:

$ python -bb -m coverage run my_program.py

I think this will do the right thing for you.