How to debug Django unit tests?
Asked Answered
S

2

9

I have a Django unit test, and I want to put print statements in it for debugging purposes but apparently django is suppressing them. How else can I print the value of a variable? I may be able to hack around with asserts, etc. but wondering how people do this.

Sharpshooter answered 13/5, 2013 at 23:8 Comment(3)
You might try looking at this post: #1118683Yonah
The answer lies in this post: #1236785Simonize
Have you tried pytest? It modifies the assert statement and prints the variables in the assertion for you, if a test fails.Deluna
E
8

You just can increase the verbosity with -v 3

Encipher answered 17/5, 2015 at 19:47 Comment(0)
A
0

just use the assert* methods:

self.assertEqual("the valule you want to know", 0)
Adrenaline answered 12/9, 2019 at 7:25 Comment(1)
hard to believe django makes something so basic so hardDollhouse

© 2022 - 2024 — McMap. All rights reserved.