Skip to content

Commit e1af2c9

Browse files
authored
Merge pull request #13748 from nicoddemus/dont-import-pytest-unittest
minor: do not import `pytest` in unittest.py
2 parents 6feed56 + 969a6f9 commit e1af2c9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/_pytest/unittest.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from _pytest.python import Function
3131
from _pytest.python import Module
3232
from _pytest.runner import CallInfo
33-
import pytest
3433

3534

3635
if sys.version_info[:2] < (3, 11):
@@ -141,7 +140,7 @@ def unittest_setup_class_fixture(
141140
cls = request.cls
142141
if _is_skipped(cls):
143142
reason = cls.__unittest_skip_why__
144-
raise pytest.skip.Exception(reason, _use_item_location=True)
143+
raise skip.Exception(reason, _use_item_location=True)
145144
if setup is not None:
146145
try:
147146
setup()
@@ -182,7 +181,7 @@ def unittest_setup_method_fixture(
182181
self = request.instance
183182
if _is_skipped(self):
184183
reason = self.__unittest_skip_why__
185-
raise pytest.skip.Exception(reason, _use_item_location=True)
184+
raise skip.Exception(reason, _use_item_location=True)
186185
if setup is not None:
187186
setup(self, request.function)
188187
yield
@@ -280,7 +279,7 @@ def addFailure(
280279

281280
def addSkip(self, testcase: unittest.TestCase, reason: str) -> None:
282281
try:
283-
raise pytest.skip.Exception(reason, _use_item_location=True)
282+
raise skip.Exception(reason, _use_item_location=True)
284283
except skip.Exception:
285284
self._addexcinfo(sys.exc_info())
286285

0 commit comments

Comments
 (0)