|
1 | 1 | from __future__ import print_function
|
2 | 2 | import os
|
3 | 3 | import pytest
|
| 4 | +from collections import OrderedDict |
4 | 5 |
|
5 | 6 | @pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
6 | 7 | def pytest_runtest_makereport(item, call):
|
@@ -44,18 +45,19 @@ def pytest_runtest_makereport(item, call):
|
44 | 45 |
|
45 | 46 |
|
46 | 47 | def _error_workflow_command(filesystempath, lineno, longrepr):
|
47 |
| - if lineno is None: |
48 |
| - if longrepr is None: |
49 |
| - return '\n::error file={}'.format(filesystempath) |
50 |
| - else: |
51 |
| - longrepr = _escape(longrepr) |
52 |
| - return '\n::error file={}::{}'.format(filesystempath, longrepr) |
| 48 | + # Build collection of arguments. Ordering is strict for easy testing |
| 49 | + details_dict = OrderedDict() |
| 50 | + details_dict["file"] = filesystempath |
| 51 | + if lineno is not None: |
| 52 | + details_dict["line"] = lineno |
| 53 | + |
| 54 | + details = ",".join("{}={}".format(k,v) for k,v in details_dict.items()) |
| 55 | + |
| 56 | + if longrepr is None: |
| 57 | + return '\n::error {}'.format(details) |
53 | 58 | else:
|
54 |
| - if longrepr is None: |
55 |
| - return '\n::error file={},line={}'.format(filesystempath, lineno) |
56 |
| - else: |
57 |
| - longrepr = _escape(longrepr) |
58 |
| - return '\n::error file={},line={}::{}'.format(filesystempath, lineno, longrepr) |
| 59 | + longrepr = _escape(longrepr) |
| 60 | + return '\n::error {}::{}'.format(details, longrepr) |
59 | 61 |
|
60 | 62 | def _escape(s):
|
61 | 63 | return s.replace('%', '%25').replace('\r', '%0D').replace('\n', '%0A')
|
0 commit comments