PytestRun test failures parsing is broken for tests in a class

Review Request #2714 - Created Aug. 27, 2015 and submitted

Information
Chris Chen
pants
2733
3cf5ae6...
Reviewers
pants-reviews
benjyw, jsirois, stuhood

Fix a bug in pytest_run where failures from tests in class are not parsed properly. For tests that are inside the class, the failure line for each test failure will look like the following:

F path/to/test_file.py::TestClassName::test_name

The regex pants uses to get the source file name was

re.compile(r'F +(.+)::(.+)')

As a result, the file path doesn't match the source of the failing target which resulted in TestFailedTaskError always have an empty failed targets list.

Here is an example of a results log from a python test target.

. science/tests/python/twitter/mde/runner/test_check_subprocess.py::TestCheckSubprocess::()::test_check_subprocess_success
F science/tests/python/twitter/mde/runner/test_check_subprocess.py::TestCheckSubprocess::()::test_log_subprocess_failure
self = <test_check_subprocess.TestCheckSubprocess object at 0x1072b6a10>

 def test_log_subprocess_failure(self):
   command = [
     'python',
     '-c',
     textwrap.dedent('''
         import sys
         sys.stdout.write("stdout\\n")
         sys.stderr.write("stderr\\n")
         sys.exit(1)''')
   ]

assert 1 == 2

E assert 1 == 2

science/tests/python/twitter/mde/runner/test_check_subprocess.py:24: AssertionError

https://github.com/pantsbuild/pants/pull/2077

Matt Olsen
John Sirois
Itay Donanhirsh
Stu Hood
Chris Chen
Review request changed

Status: Closed (submitted)

Change Summary:

Merged as 9d0bbf04a848708ae98a6d245bdd3576851ccd7a

Loading...