From 810db2726d3ef31f58cdf44eca1a5bb30c66bee0 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Tue, 15 Oct 2019 18:57:59 -0700 Subject: [PATCH 1/3] Put the 4.6 changelogs together --- CHANGELOG.rst | 53 +++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2d27b5e65..07e8d26cc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -27,33 +27,6 @@ Bug Fixes - `#5902 `_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``. -pytest 4.6.6 (2019-10-11) -========================= - -Bug Fixes ---------- - -- `#5523 `_: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+. - - -- `#5537 `_: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the - standard library on Python 3.8+. - - -- `#5806 `_: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text". - - -- `#5902 `_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``. - - - -Trivial/Internal Changes ------------------------- - -- `#5801 `_: Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing. - - - pytest 5.2.0 (2019-09-28) ========================= @@ -524,6 +497,32 @@ Improved Documentation - `#5416 `_: Fix PytestUnknownMarkWarning in run/skip example. +pytest 4.6.6 (2019-10-11) +========================= + +Bug Fixes +--------- + +- `#5523 `_: Fixed using multiple short options together in the command-line (for example ``-vs``) in Python 3.8+. + + +- `#5537 `_: Replace ``importlib_metadata`` backport with ``importlib.metadata`` from the + standard library on Python 3.8+. + + +- `#5806 `_: Fix "lexer" being used when uploading to bpaste.net from ``--pastebin`` to "text". + + +- `#5902 `_: Fix warnings about deprecated ``cmp`` attribute in ``attrs>=19.2``. + + + +Trivial/Internal Changes +------------------------ + +- `#5801 `_: Fixes python version checks (detected by ``flake8-2020``) in case python4 becomes a thing. + + pytest 4.6.5 (2019-08-05) ========================= From 96de23279165af589822f54365f31925390f434d Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 26 Oct 2019 16:00:04 +0300 Subject: [PATCH 2/3] Replace a few outdated references to py.test with pytest --- testing/freeze/runtests_script.py | 2 +- testing/python/collect.py | 2 +- testing/test_reports.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/testing/freeze/runtests_script.py b/testing/freeze/runtests_script.py index d03bca840..591863016 100644 --- a/testing/freeze/runtests_script.py +++ b/testing/freeze/runtests_script.py @@ -1,6 +1,6 @@ """ This is the script that is actually frozen into an executable: simply executes -py.test main(). +pytest main(). """ if __name__ == "__main__": diff --git a/testing/python/collect.py b/testing/python/collect.py index e6dd3e870..f0c12df16 100644 --- a/testing/python/collect.py +++ b/testing/python/collect.py @@ -1148,7 +1148,7 @@ def test_dont_collect_non_function_callable(testdir): """Test for issue https://github.com/pytest-dev/pytest/issues/331 In this case an INTERNALERROR occurred trying to report the failure of - a test like this one because py test failed to get the source lines. + a test like this one because pytest failed to get the source lines. """ testdir.makepyfile( """ diff --git a/testing/test_reports.py b/testing/test_reports.py index 8bac0243a..9f6c56186 100644 --- a/testing/test_reports.py +++ b/testing/test_reports.py @@ -133,17 +133,17 @@ class TestReportSerialization: """ reprec = testdir.inline_runsource( """ - import py + import pytest def test_pass(): pass def test_fail(): 0/0 - @py.test.mark.skipif("True") + @pytest.mark.skipif("True") def test_skip(): pass def test_skip_imperative(): - py.test.skip("hello") - @py.test.mark.xfail("True") + pytest.skip("hello") + @pytest.mark.xfail("True") def test_xfail(): 0/0 def test_xfail_imperative(): - py.test.xfail("hello") + pytest.xfail("hello") """ ) reports = reprec.getreports("pytest_runtest_logreport") From 0b8c35516fc3da230e6ce177b76f8af0d5a14ed1 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Sat, 26 Oct 2019 15:47:48 +0300 Subject: [PATCH 3/3] Replace py.io.TextIO with io.StringIO In Python3, py.io.TextIO is just an alias to io.StringIO. Remove the indirection. --- src/_pytest/_code/code.py | 3 ++- src/_pytest/logging.py | 7 +++---- src/_pytest/pytester.py | 3 ++- src/_pytest/reports.py | 3 ++- testing/test_capture.py | 9 ++++----- testing/test_resultlog.py | 13 ++++++------- testing/test_terminal.py | 3 ++- 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 534bfe2a8..b778c0db6 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -4,6 +4,7 @@ import sys import traceback from inspect import CO_VARARGS from inspect import CO_VARKEYWORDS +from io import StringIO from traceback import format_exception_only from types import CodeType from types import TracebackType @@ -865,7 +866,7 @@ class TerminalRepr: def __str__(self): # FYI this is called from pytest-xdist's serialization of exception # information. - io = py.io.TextIO() + io = StringIO() tw = py.io.TerminalWriter(file=io) self.toterminal(tw) return io.getvalue().strip() diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py index 054bfc866..de8576910 100644 --- a/src/_pytest/logging.py +++ b/src/_pytest/logging.py @@ -2,8 +2,7 @@ import logging import re from contextlib import contextmanager - -import py +from io import StringIO import pytest from _pytest.compat import nullcontext @@ -218,7 +217,7 @@ class LogCaptureHandler(logging.StreamHandler): def __init__(self): """Creates a new log handler.""" - logging.StreamHandler.__init__(self, py.io.TextIO()) + logging.StreamHandler.__init__(self, StringIO()) self.records = [] def emit(self, record): @@ -228,7 +227,7 @@ class LogCaptureHandler(logging.StreamHandler): def reset(self): self.records = [] - self.stream = py.io.TextIO() + self.stream = StringIO() class LogCaptureFixture: diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 0f3460741..e1db9b17b 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -10,6 +10,7 @@ import time import traceback from collections.abc import Sequence from fnmatch import fnmatch +from io import StringIO from weakref import WeakKeyDictionary import py @@ -1218,7 +1219,7 @@ def getdecoded(out): class LineComp: def __init__(self): - self.stringio = py.io.TextIO() + self.stringio = StringIO() def assert_contains_lines(self, lines2): """Assert that lines2 are contained (linearly) in lines1. diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py index d8030b926..49eec6129 100644 --- a/src/_pytest/reports.py +++ b/src/_pytest/reports.py @@ -1,3 +1,4 @@ +from io import StringIO from pprint import pprint from typing import Optional from typing import Union @@ -180,7 +181,7 @@ class BaseReport: def _report_unserialization_failure(type_name, report_class, reportdict): url = "https://github.com/pytest-dev/pytest/issues" - stream = py.io.TextIO() + stream = StringIO() pprint("-" * 100, stream=stream) pprint("INTERNALERROR: Unknown entry type returned: %s" % type_name, stream=stream) pprint("report_name: %s" % report_class, stream=stream) diff --git a/testing/test_capture.py b/testing/test_capture.py index f5b193597..139655c72 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -5,10 +5,9 @@ import pickle import subprocess import sys import textwrap +from io import StringIO from io import UnsupportedOperation -import py - import pytest from _pytest import capture from _pytest.capture import CaptureManager @@ -892,10 +891,10 @@ def test_dupfile_on_bytesio(): def test_dupfile_on_textio(): - tio = py.io.TextIO() - f = capture.safe_text_dupfile(tio, "wb") + sio = StringIO() + f = capture.safe_text_dupfile(sio, "wb") f.write("hello") - assert tio.getvalue() == "hello" + assert sio.getvalue() == "hello" assert not hasattr(f, "name") diff --git a/testing/test_resultlog.py b/testing/test_resultlog.py index 9e8f62135..b6f957b40 100644 --- a/testing/test_resultlog.py +++ b/testing/test_resultlog.py @@ -1,6 +1,5 @@ import os - -import py +from io import StringIO import _pytest._code import pytest @@ -13,7 +12,7 @@ pytestmark = pytest.mark.filterwarnings("ignore:--result-log is deprecated") def test_write_log_entry(): reslog = ResultLog(None, None) - reslog.logfile = py.io.TextIO() + reslog.logfile = StringIO() reslog.write_log_entry("name", ".", "") entry = reslog.logfile.getvalue() assert entry[-1] == "\n" @@ -21,7 +20,7 @@ def test_write_log_entry(): assert len(entry_lines) == 1 assert entry_lines[0] == ". name" - reslog.logfile = py.io.TextIO() + reslog.logfile = StringIO() reslog.write_log_entry("name", "s", "Skipped") entry = reslog.logfile.getvalue() assert entry[-1] == "\n" @@ -30,7 +29,7 @@ def test_write_log_entry(): assert entry_lines[0] == "s name" assert entry_lines[1] == " Skipped" - reslog.logfile = py.io.TextIO() + reslog.logfile = StringIO() reslog.write_log_entry("name", "s", "Skipped\n") entry = reslog.logfile.getvalue() assert entry[-1] == "\n" @@ -39,7 +38,7 @@ def test_write_log_entry(): assert entry_lines[0] == "s name" assert entry_lines[1] == " Skipped" - reslog.logfile = py.io.TextIO() + reslog.logfile = StringIO() longrepr = " tb1\n tb 2\nE tb3\nSome Error" reslog.write_log_entry("name", "F", longrepr) entry = reslog.logfile.getvalue() @@ -118,7 +117,7 @@ class TestWithFunctionIntegration: raise ValueError except ValueError: excinfo = _pytest._code.ExceptionInfo.from_current() - reslog = ResultLog(None, py.io.TextIO()) + reslog = ResultLog(None, StringIO()) reslog.pytest_internalerror(excinfo.getrepr(style=style)) entry = reslog.logfile.getvalue() entry_lines = entry.splitlines() diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 88f96f894..2cdfc6ca8 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -5,6 +5,7 @@ import collections import os import sys import textwrap +from io import StringIO import pluggy import py @@ -268,7 +269,7 @@ class TestTerminal: def test_rewrite(self, testdir, monkeypatch): config = testdir.parseconfig() - f = py.io.TextIO() + f = StringIO() monkeypatch.setattr(f, "isatty", lambda *args: True) tr = TerminalReporter(config, f) tr._tw.fullwidth = 10