Merge pull request #7056 from bluetech/rm-test_monkeypatch-oldstyleclass
Remove Python 2 compat check in test_monkeypatch.py
This commit is contained in:
		
						commit
						f0d1ccd32f
					
				| 
						 | 
					@ -4,8 +4,12 @@ import sys
 | 
				
			||||||
import textwrap
 | 
					import textwrap
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pytest
 | 
					import pytest
 | 
				
			||||||
 | 
					from _pytest.compat import TYPE_CHECKING
 | 
				
			||||||
from _pytest.monkeypatch import MonkeyPatch
 | 
					from _pytest.monkeypatch import MonkeyPatch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if TYPE_CHECKING:
 | 
				
			||||||
 | 
					    from typing import Type
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@pytest.fixture
 | 
					@pytest.fixture
 | 
				
			||||||
def mp():
 | 
					def mp():
 | 
				
			||||||
| 
						 | 
					@ -331,33 +335,20 @@ def test_importerror(testdir):
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SampleNew:
 | 
					class Sample:
 | 
				
			||||||
    @staticmethod
 | 
					    @staticmethod
 | 
				
			||||||
    def hello():
 | 
					    def hello() -> bool:
 | 
				
			||||||
        return True
 | 
					        return True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SampleNewInherit(SampleNew):
 | 
					class SampleInherit(Sample):
 | 
				
			||||||
    pass
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class SampleOld:
 | 
					 | 
				
			||||||
    # oldstyle on python2
 | 
					 | 
				
			||||||
    @staticmethod
 | 
					 | 
				
			||||||
    def hello():
 | 
					 | 
				
			||||||
        return True
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class SampleOldInherit(SampleOld):
 | 
					 | 
				
			||||||
    pass
 | 
					    pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@pytest.mark.parametrize(
 | 
					@pytest.mark.parametrize(
 | 
				
			||||||
    "Sample",
 | 
					    "Sample", [Sample, SampleInherit], ids=["new", "new-inherit"],
 | 
				
			||||||
    [SampleNew, SampleNewInherit, SampleOld, SampleOldInherit],
 | 
					 | 
				
			||||||
    ids=["new", "new-inherit", "old", "old-inherit"],
 | 
					 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
def test_issue156_undo_staticmethod(Sample):
 | 
					def test_issue156_undo_staticmethod(Sample: "Type[Sample]") -> None:
 | 
				
			||||||
    monkeypatch = MonkeyPatch()
 | 
					    monkeypatch = MonkeyPatch()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    monkeypatch.setattr(Sample, "hello", None)
 | 
					    monkeypatch.setattr(Sample, "hello", None)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue