Skip to content

Commit 0ac11b1

Browse files
committed
Add the "sb" pytest fixture
1 parent d6fc08c commit 0ac11b1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

seleniumbase/plugins/pytest_plugin.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,26 @@ def pytest_runtest_teardown(item):
384384
pass
385385

386386

387+
@pytest.fixture()
388+
def sb(request):
389+
from seleniumbase import BaseCase
390+
391+
class BaseClass(BaseCase):
392+
def base_method():
393+
pass
394+
395+
if request.cls:
396+
request.cls.sb = BaseClass("base_method")
397+
request.cls.sb.setUp()
398+
yield request.cls.sb
399+
request.cls.sb.tearDown()
400+
else:
401+
sb = BaseClass("base_method")
402+
sb.setUp()
403+
yield sb
404+
sb.tearDown()
405+
406+
387407
@pytest.mark.hookwrapper
388408
def pytest_runtest_makereport(item, call):
389409
pytest_html = item.config.pluginmanager.getplugin('html')

0 commit comments

Comments
 (0)