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.

Nima
  • 854
  • 3
  • 11
  • 18
  • You might try looking at this post: http://stackoverflow.com/questions/1118183/how-to-debug-in-django-the-good-way – bitfish May 13 '13 at 23:27
  • 1
    The answer lies in this post: http://stackoverflow.com/questions/1236285/how-do-i-see-stdout-when-running-django-tests – CppLearner May 14 '13 at 01:27
  • Have you tried [`pytest`](https://pytest.org/en/latest/)? It modifies the `assert` statement and prints the variables in the assertion for you, if a test fails. – Boris Verkhovskiy Sep 12 '19 at 14:34

2 Answers2

10

You just can increase the verbosity with -v 3

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
Lioman
  • 529
  • 8
  • 20
0

just use the assert* methods:

self.assertEqual("the valule you want to know", 0)
Gary 612
  • 47
  • 3