piyo
piyo

Reputation: 471

How to tell at runtime if you're inside of a unit test in Python?

Does anyone know the least hacky way of determining if Python code is being run by a unit test?

Thanks!

Upvotes: 2

Views: 75

Answers (1)

James Mills
James Mills

Reputation: 19030

I agree with all the comments.

Don't do this.

Your function/class/component should NOT behave differently under testing.

Upvotes: 1

Related Questions