Migrate to pytest
ClosedPublic

Authored by Ladsgroup on Dec 3 2017, 5:34 PM.

Details

Reviewers
mmodell
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Release-Engineering-Team
Commits
rMSCAd493cbe4fefb: Migrate to pytest
Patch without arc
git checkout -b D903 && curl -L https://phabricator.wikimedia.org/D903?download=true | git apply
Summary

Bug: T179885

Diff Detail

Repository
rMSCA Scap
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
Ladsgroup created this revision.Dec 3 2017, 5:34 PM
Restricted Application added a reviewer: Restricted Owners Package.Dec 3 2017, 5:34 PM
Restricted Application added a reviewer: mmodell. · View Herald TranscriptDec 3 2017, 5:34 PM
Restricted Application added a reviewer: Release-Engineering-Team. · View Herald Transcript
Restricted Application added a project: Release-Engineering-Team. · View Herald Transcript

This is the first parts and probably should not be merged at this stage, will work on it more during the week.

demon updated this revision to Diff 2396.Dec 7 2017, 9:46 PM
demon added a subscriber: demon.
  • Add pytest to test-requirements list
demon added a comment.Dec 7 2017, 9:50 PM

Ok, now that we sorted the dependency we're down to two actual failures:

21:47:54 ERROR: Ensure TypeError message is helpful.
21:47:54 ----------------------------------------------------------------------
21:47:54 Traceback (most recent call last):
21:47:54   File "/srv/workspace/tests/scap/test_log.py", line 250, in test_helpful_typeerror
21:47:54     assert args[0] in str(e.exception)
21:47:54 AttributeError: 'ExceptionInfo' object has no attribute 'exception'
21:47:54 
21:47:54 ======================================================================
21:47:54 ERROR: test_check_valid_syntax__invalid_php_file_raise_exception (tests.scap.test_tasks.TasksTest)
21:47:54 ----------------------------------------------------------------------
21:47:54 Traceback (most recent call last):
21:47:54   File "/srv/workspace/tests/scap/test_tasks.py", line 26, in test_check_valid_syntax__invalid_php_file_raise_exception
21:47:54     exc = cm.exception
21:47:54 AttributeError: 'ExceptionInfo' object has no attribute 'exception'
21:47:54 -------------------- >> begin captured logging << --------------------
21:47:54 check_php_syntax: DEBUG: Running command: `find -O2 '/tmp/tmpt41YZF.php' -not -type d -name '*.php' -not -name 'autoload_static.php'  -or -name '*.inc' | xargs -n1 -P1 -exec php -l >/dev/null 2>&1`
demon updated this revision to Diff 2397.Dec 7 2017, 9:57 PM
  • pytest ExceptionInfo classes store their exceptions as a variable called value
Ladsgroup requested review of this revision.Dec 7 2017, 9:59 PM

Seems to work when I run py.test, however, arc unit doesn't output anything.

mmodell updated this revision to Diff 2398.Dec 9 2017, 3:41 AM

Fix arc unit by changing the unit test engine in .arcconfig

Also add htmlcov and .cache to the .gitignore

demon added a comment.Dec 11 2017, 3:33 PM

I already did those things in D902, needs a rebase.

demon updated this revision to Diff 2437.Dec 20 2017, 7:50 AM
  • Rebased, etc
demon added a comment.Dec 20 2017, 7:51 AM

Ideally we can move to pytest-style fixtures and get rid of the unittest.TestCase classes, but this does most of the hard work already.

demon updated this revision to Diff 2438.Dec 20 2017, 7:56 AM
  • Fix ExceptionInfo/Exception split
mmodell accepted this revision as: mmodell.Fri, Jan 5, 8:06 PM
This revision is now accepted and ready to land.Fri, Jan 5, 8:06 PM
This revision was automatically updated to reflect the committed changes.