diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2020-08-17 18:10:27 -0300 |
---|---|---|
committer | Bruno Oliveira <nicoddemus@gmail.com> | 2020-08-19 08:14:28 -0300 |
commit | ef946d557cc7b7f030805b94c1dbae51f39fcce4 (patch) | |
tree | 9741d0c233e32c4bfe83b7180bf7476e44c2b306 /src | |
parent | b32c48ee0519f7469077ed9878bbc1d550660d78 (diff) | |
download | pytest-ef946d557cc7b7f030805b94c1dbae51f39fcce4.tar.gz |
Remove resultlog plugin
Diffstat (limited to 'src')
-rw-r--r-- | src/_pytest/config/__init__.py | 1 | ||||
-rw-r--r-- | src/_pytest/deprecated.py | 6 | ||||
-rw-r--r-- | src/_pytest/resultlog.py | 108 |
3 files changed, 0 insertions, 115 deletions
diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index 453dd8345..1c6ad3288 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -239,7 +239,6 @@ default_plugins = essential_plugins + ( "nose", "assertion", "junitxml", - "resultlog", "doctest", "cacheprovider", "freeze_support", diff --git a/src/_pytest/deprecated.py b/src/_pytest/deprecated.py index 500fbe2f8..ecdb60d37 100644 --- a/src/_pytest/deprecated.py +++ b/src/_pytest/deprecated.py @@ -25,12 +25,6 @@ FILLFUNCARGS = PytestDeprecationWarning( "function._request._fillfixtures() instead if you cannot avoid reaching into internals." ) -RESULT_LOG = PytestDeprecationWarning( - "--result-log is deprecated, please try the new pytest-reportlog plugin.\n" - "See https://docs.pytest.org/en/stable/deprecations.html#result-log-result-log for more information." -) - - PYTEST_COLLECT_MODULE = UnformattedWarning( PytestDeprecationWarning, "pytest.collect.{name} was moved to pytest.{name}\n" diff --git a/src/_pytest/resultlog.py b/src/_pytest/resultlog.py deleted file mode 100644 index 686f7f3b0..000000000 --- a/src/_pytest/resultlog.py +++ /dev/null @@ -1,108 +0,0 @@ -"""log machine-parseable test session result information to a plain text file.""" -import os -from typing import IO -from typing import Union - -from _pytest._code.code import ExceptionRepr -from _pytest.config import Config -from _pytest.config.argparsing import Parser -from _pytest.reports import CollectReport -from _pytest.reports import TestReport -from _pytest.store import StoreKey - - -resultlog_key = StoreKey["ResultLog"]() - - -def pytest_addoption(parser: Parser) -> None: - group = parser.getgroup("terminal reporting", "resultlog plugin options") - group.addoption( - "--resultlog", - "--result-log", - action="store", - metavar="path", - default=None, - help="DEPRECATED path for machine-readable result log.", - ) - - -def pytest_configure(config: Config) -> None: - resultlog = config.option.resultlog - # Prevent opening resultlog on worker nodes (xdist). - if resultlog and not hasattr(config, "workerinput"): - dirname = os.path.dirname(os.path.abspath(resultlog)) - if not os.path.isdir(dirname): - os.makedirs(dirname) - logfile = open(resultlog, "w", 1) # line buffered - config._store[resultlog_key] = ResultLog(config, logfile) - config.pluginmanager.register(config._store[resultlog_key]) - - from _pytest.deprecated import RESULT_LOG - from _pytest.warnings import _issue_warning_captured - - _issue_warning_captured(RESULT_LOG, config.hook, stacklevel=2) - - -def pytest_unconfigure(config: Config) -> None: - resultlog = config._store.get(resultlog_key, None) - if resultlog: - resultlog.logfile.close() - del config._store[resultlog_key] - config.pluginmanager.unregister(resultlog) - - -class ResultLog: - def __init__(self, config: Config, logfile: IO[str]) -> None: - self.config = config - self.logfile = logfile # preferably line buffered - - def write_log_entry(self, testpath: str, lettercode: str, longrepr: str) -> None: - print("{} {}".format(lettercode, testpath), file=self.logfile) - for line in longrepr.splitlines(): - print(" %s" % line, file=self.logfile) - - def log_outcome( - self, report: Union[TestReport, CollectReport], lettercode: str, longrepr: str - ) -> None: - testpath = getattr(report, "nodeid", None) - if testpath is None: - testpath = report.fspath - self.write_log_entry(testpath, lettercode, longrepr) - - def pytest_runtest_logreport(self, report: TestReport) -> None: - if report.when != "call" and report.passed: - return - res = self.config.hook.pytest_report_teststatus( - report=report, config=self.config - ) - code = res[1] # type: str - if code == "x": - longrepr = str(report.longrepr) - elif code == "X": - longrepr = "" - elif report.passed: - longrepr = "" - elif report.skipped: - assert isinstance(report.longrepr, tuple) - longrepr = str(report.longrepr[2]) - else: - longrepr = str(report.longrepr) - self.log_outcome(report, code, longrepr) - - def pytest_collectreport(self, report: CollectReport) -> None: - if not report.passed: - if report.failed: - code = "F" - longrepr = str(report.longrepr) - else: - assert report.skipped - code = "S" - longrepr = "%s:%d: %s" % report.longrepr # type: ignore - self.log_outcome(report, code, longrepr) - - def pytest_internalerror(self, excrepr: ExceptionRepr) -> None: - if excrepr.reprcrash is not None: - path = excrepr.reprcrash.path - else: - path = "cwd:%s" % os.getcwd() - self.write_log_entry(path, "!", str(excrepr)) |