Skip to content

Commit ded4186

Browse files
committed
Remove a bunch of now-unused code
Missed in ce61e04.
1 parent 192b634 commit ded4186

File tree

1 file changed

+0
-67
lines changed

1 file changed

+0
-67
lines changed

pytest_django/plugin.py

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import os
1111
import pathlib
1212
import sys
13-
import types
1413

1514
import pytest
1615

@@ -333,72 +332,6 @@ def pytest_configure():
333332
_setup_django()
334333

335334

336-
def _classmethod_is_defined_at_leaf(cls, method_name):
337-
super_method = None
338-
339-
for base_cls in cls.__mro__[1:]: # pragma: no branch
340-
super_method = base_cls.__dict__.get(method_name)
341-
if super_method is not None:
342-
break
343-
344-
assert super_method is not None, (
345-
"%s could not be found in base classes" % method_name
346-
)
347-
348-
method = getattr(cls, method_name)
349-
350-
try:
351-
f = method.__func__
352-
except AttributeError:
353-
pytest.fail("{}.{} should be a classmethod".format(cls, method_name))
354-
return f is not super_method.__func__
355-
356-
357-
_disabled_classmethods = {}
358-
359-
360-
def _disable_class_methods(cls):
361-
if cls in _disabled_classmethods:
362-
return
363-
364-
_disabled_classmethods[cls] = (
365-
# Get the classmethod object (not the resulting bound method),
366-
# otherwise inheritance will be broken when restoring.
367-
cls.__dict__.get("setUpClass"),
368-
_classmethod_is_defined_at_leaf(cls, "setUpClass"),
369-
cls.__dict__.get("tearDownClass"),
370-
_classmethod_is_defined_at_leaf(cls, "tearDownClass"),
371-
)
372-
373-
cls.setUpClass = types.MethodType(lambda cls: None, cls)
374-
cls.tearDownClass = types.MethodType(lambda cls: None, cls)
375-
376-
377-
def _restore_class_methods(cls):
378-
(
379-
setUpClass,
380-
restore_setUpClass,
381-
tearDownClass,
382-
restore_tearDownClass,
383-
) = _disabled_classmethods.pop(cls)
384-
385-
try:
386-
del cls.setUpClass
387-
except AttributeError:
388-
raise
389-
390-
try:
391-
del cls.tearDownClass
392-
except AttributeError:
393-
pass
394-
395-
if restore_setUpClass:
396-
cls.setUpClass = setUpClass
397-
398-
if restore_tearDownClass:
399-
cls.tearDownClass = tearDownClass
400-
401-
402335
@pytest.hookimpl(tryfirst=True)
403336
def pytest_collection_modifyitems(items):
404337
# If Django is not configured we don't need to bother

0 commit comments

Comments
 (0)