on-internet
← Community

Is doctest riskier than unittest or pytest because of exec()?

Stack Overflow ·

I recently read on Real Python that using doctest is risky because it's based on exec() and therefore you are open to the execution of arbitrary code. The article states that you must be very aware of the contents of the test code in the docstrings. I'm a bit confused about this. Can't tests using unittest or pytest also have malicious code? What makes doctest more susceptible to security issues compared to other testing frameworks?

Comments

Sign in or sign up to comment and upvote.

No comments yet.