Prevent truncation of long lines in pytest

I wrote a test harness for system tests of our code using pytest. These tests are used in our continuous integration system, so I use the junit xml output option. Trimming long lines of pytest is causing me problems. I know that I can prevent it from using the -vv option, but then this gives detailed output for the results of each test, which is hard to read. Essentially, I want another way to prevent the truncation of a long line, at least in the junit xml file. If it also worked on console output, that would be better, but not significant.

Our code generates reports with a large number of values, and I compare the output with a set of results, which, as you know, is correct. I report all fields that are an error, not just the first error. Therefore, I generate a list of strings with one error per line. Then I join the lines with the newlines to create one long line and a long line containing all the errors. If the statement fails, I need to see the entire contents of the line, which may be several hundred lines.

errors = [] error.extend(get_report_errors()) s = '\n'.join(errors) assert (s == '') 

Any suggestions

I am using python 2.6 and 2.7 and pytest 2.3.5. I can upgrade the version of pytest needed.

+7
integration-testing truncation
source share
1 answer

You can use the tb flag, this is the trace output for pytest. There are several options for this: --tb=style traceback print mode (auto/long/short/line/native/no)

You need to understand what is best for you.

+1
source share

All Articles