MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / main

Method main

seleniumbase/fixtures/base_case.py:197–227  ·  view source on GitHub ↗

Run pytest if file was called with "python". Usage example: from seleniumbase import BaseCase BaseCase.main(__name__, __file__) class MyTestClass(BaseCase): def test_example(self): pass The run command:

(self, name, file, *args)

Source from the content-addressed store, hash-verified

195
196 @classmethod
197 def main(self, name, file, *args):
198 """Run pytest if file was called with "python".
199 Usage example:
200
201 from seleniumbase import BaseCase
202 BaseCase.main(__name__, __file__)
203
204 class MyTestClass(BaseCase):
205 def test_example(self):
206 pass
207
208 The run command:
209 python my_test.py # (Instead of "pytest my_test.py")
210
211 This is useful when sharing code with people who may not be aware
212 that SeleniumBase tests are run with "pytest" instead of "python".
213 Now, if they accidentally type "python", the tests will still run.
214 Eg. "python my_test.py" instead of "pytest my_test.py"."""
215 if name == "__main__": # Test called with "python"
216 import subprocess
217 all_args = []
218 for arg in args:
219 all_args.append(arg)
220 for arg in sys.argv[1:]:
221 all_args.append(arg)
222 # See: https://stackoverflow.com/a/54666289/7058266
223 # from pytest import main as pytest_main
224 # pytest_main([file, "-s", *all_args])
225 subprocess.call(
226 [sys.executable, "-m", "pytest", file, "-s", *all_args]
227 )
228
229 def open(self, url, **kwargs):
230 """Navigates the current browser window to the specified page."""

Callers 15

mainFunction · 0.80
get_driverFunction · 0.80
get_local_driverFunction · 0.80
autoMethod · 0.80
__init__Method · 0.80
mainFunction · 0.80
mainFunction · 0.80
test_demo_site.pyFile · 0.80
test_fail.pyFile · 0.80
test_docs_site.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected