Page MenuHomePhabricator

[Discuss] Moving from nosetests to pytest
Closed, ResolvedPublic

Description

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 nose.tools 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/trivial.py", 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: https://docs.pytest.org/en/latest/getting-started.html

I made this POC to check if the failure looks okay or not: https://travis-ci.org/wiki-ai/ores/builds/274682817?utm_source=github_status&utm_medium=notification 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.