From 08b3d3717761fa5bd9b1a85ddff444aacec15c32 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Thu, 9 Apr 2020 17:11:18 +0300 Subject: [PATCH] Remove Python 2 compat check in test_monkeypatch.py Presumably it used to test old-style vs. new-style classes, but in the Python 3 conversion SampleNew and SampleOld became the same. --- testing/test_monkeypatch.py | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index eee8baf3a..8c2fceb3f 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -4,8 +4,12 @@ import sys import textwrap import pytest +from _pytest.compat import TYPE_CHECKING from _pytest.monkeypatch import MonkeyPatch +if TYPE_CHECKING: + from typing import Type + @pytest.fixture def mp(): @@ -331,33 +335,20 @@ def test_importerror(testdir): ) -class SampleNew: +class Sample: @staticmethod - def hello(): + def hello() -> bool: return True -class SampleNewInherit(SampleNew): - pass - - -class SampleOld: - # oldstyle on python2 - @staticmethod - def hello(): - return True - - -class SampleOldInherit(SampleOld): +class SampleInherit(Sample): pass @pytest.mark.parametrize( - "Sample", - [SampleNew, SampleNewInherit, SampleOld, SampleOldInherit], - ids=["new", "new-inherit", "old", "old-inherit"], + "Sample", [Sample, SampleInherit], ids=["new", "new-inherit"], ) -def test_issue156_undo_staticmethod(Sample): +def test_issue156_undo_staticmethod(Sample: "Type[Sample]") -> None: monkeypatch = MonkeyPatch() monkeypatch.setattr(Sample, "hello", None)