Search code examples
pythondjangounit-testingintegration-testingdjango-testing

How to give a name to test?


How do I give a name to unit test in Django?

With RSpec I would do something like

it 'has a name!' do
  # do something
end

But is it possible with Django so I can see normal names in PyCharm instead of this:

enter image description here


Solution

  • You could use a comment above the method name # ... and set the the test suite verbosity to 2. This will print a description along with the test like so:

    <test name> test that so and so happens ... ok