Page MenuHomePhabricator

[Discuss] Moving from nosetests to pytest
Closed, ResolvedPublic


It seems development of nosetests has been stalled and pytest is gaining attention. Moving away from nosetests won't be really hard but implementing nosetests for stuff like flask apps is not easy but pytest has even library for testing flask apps pytest-flask

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

One thing that I discussed with @Ladsgroup is the helper functions in nosetools. E.g.

>>> from import eq_
>>> eq_(1, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/halfak/venv/3.5/lib/python3.5/site-packages/nose/tools/", line 29, in eq_
    raise AssertionError(msg or "%r != %r" % (a, b))
AssertionError: 1 != 3

To achieve the equivalent with an assert, you must do:

>>> assert 1 == 3, "{0} != {1}".format(1, 3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError: 1 != 3

Does pytest have anything like that?

If that's what we do with 'eq_', I think pytest automatically covers that. See a failed example in here:

I made this POC to check if the failure looks okay or not: I think it's better than nosetests but it doesn't report coverage :/ I need to find a way for that.

Talked to @Ladsgroup. He's going to present this at an upcoming Sync meeting so we can discuss the switch.