mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
PY-32605: use repr for diff in pytest
``assert "[]" == []`` ``assert "123" == 123`` is only displayed correctly when we ``repr`` both GitOrigin-RevId: ff962dffe7341e95ceeda613e557e9de5cb2620f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
218c8418ba
commit
cd4e6494a8
@@ -10,6 +10,7 @@ from pkg_resources import iter_entry_points
|
||||
from _jb_runner_tools import jb_patch_separator, jb_doc_args, JB_DISABLE_BUFFERING, start_protocol, parse_arguments, \
|
||||
set_parallel_mode
|
||||
from teamcity import pytest_plugin
|
||||
import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
path, targets, additional_args = parse_arguments()
|
||||
@@ -46,5 +47,5 @@ if __name__ == '__main__':
|
||||
set_parallel_mode()
|
||||
start_protocol()
|
||||
|
||||
|
||||
os.environ["_JB_REPR_DIFF"] = "1"
|
||||
sys.exit(pytest.main(args, plugins_to_load + [Plugin]))
|
||||
|
||||
@@ -12,20 +12,24 @@ tests under TeamCity build.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import sys
|
||||
import traceback
|
||||
from datetime import timedelta
|
||||
|
||||
from teamcity.messages import TeamcityServiceMessages
|
||||
from teamcity.common import convert_error_to_string, dump_test_stderr, dump_test_stdout
|
||||
from teamcity import is_running_under_teamcity
|
||||
from teamcity import diff_tools
|
||||
from teamcity import is_running_under_teamcity
|
||||
from teamcity.common import convert_error_to_string, dump_test_stderr, dump_test_stdout
|
||||
from teamcity.messages import TeamcityServiceMessages
|
||||
|
||||
diff_tools.patch_unittest_diff()
|
||||
_ASSERTION_FAILURE_KEY = '_teamcity_assertion_failure'
|
||||
|
||||
|
||||
def _repr_if_needed(obj):
|
||||
return repr(obj) if '_JB_REPR_DIFF' in os.environ else obj
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
group = parser.getgroup("terminal reporting", "reporting", after="general")
|
||||
|
||||
@@ -282,7 +286,7 @@ class EchoTeamCityMessages(object):
|
||||
self.report_test_finished(test_id, duration)
|
||||
|
||||
def pytest_assertrepr_compare(self, config, op, left, right):
|
||||
setattr(self.current_test_item, _ASSERTION_FAILURE_KEY, (op, left, right))
|
||||
setattr(self.current_test_item, _ASSERTION_FAILURE_KEY, (op, _repr_if_needed(left), _repr_if_needed(right)))
|
||||
|
||||
def pytest_runtest_logreport(self, report):
|
||||
"""
|
||||
|
||||
@@ -116,8 +116,8 @@ public final class PythonPyTestingTest extends PyEnvTestCase {
|
||||
@NotNull final String stderr,
|
||||
@NotNull final String all, int exitCode) {
|
||||
|
||||
final String expectedConsoleText = "Expected :expected\n" +
|
||||
"Actual :actual\n" +
|
||||
final String expectedConsoleText = "Expected :'expected'\n" +
|
||||
"Actual :'actual'\n" +
|
||||
"<Click to see difference>";
|
||||
assertThat("No diff", runner.getAllConsoleText(), containsString(expectedConsoleText));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user