-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to pytest #788
Switch to pytest #788
Conversation
Still just testing stuff :)
Might as well have our tests look good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work!
A few minor comments. Also, as discussed, please have the unitests classes inherit from object
.
[report] | ||
omit = | ||
tests/ | ||
telegram/vendor/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing this file is in order to switch to codecov?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite, it's moved to setup.cfg so it's together with the pytest config
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy'* ]]; then pip install ujson; fi | ||
|
||
script: | ||
- python travis.py | ||
- pytest -v --cov=telegram | ||
|
||
after_success: | ||
coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aren't we switching out from coveralls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are, but that's not in this PR
pytest_migrate.py
Outdated
new_class = re.sub(r'self.json_dict', r'json_dict', new_class) | ||
|
||
new_text += new_class | ||
new_file = Path('pytests/' + sys.argv[1]).open('w', encoding='UTF-8').write(new_text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this file in git?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, no we do indeed not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove then?
|
||
''' Commented out, because it would cause "Too Many Requests (429)" errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have this comment copied to the new tests as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's marked as xfail if it raises RetryError or if on pypy (where it's strangely more unstable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This is a joint PR between me and @Eldinnie.
This completes the move to the pytest testing framework. Tests are now run using (after installing
requirements-dev.txt
:# -v means verbose $ pytest -v
With this our coverage once again reaches > 90% and with #778, it should increase even further (this is due to removing de_json tests from the objects mentioned in that issue, since it seemed stupid to port tests that were just gonna get removed)
Other changes
This PR also includes some other changes related to tests without actually being tests
.coveragerc
) tosetup.cfg
for two reasons:pragma: no cover
comment worked, but those lines should indeed be excluded from coverage)Game
andMessage
now default tolist()
instead ofNone
since they are indeed lists no matter whateffective_attachment
"Because a few of the possible attachments will evaluate to an empty list if not present (photo for instance). This way it covers those too." - @Eldinnie.Opening a new PR instead of piggy bagging on #757, since it's gonna be squashed and @Eldinnie didn't care for the Github credit (on the projects collaborators view and on his profile), the other alternative was a manually squash a lot of stuff which wouldn't just be quite ugly but also time consuming