Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
repos:
- repo: https://github.com/psf/black
rev: 24.1.1
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.1.0
hooks:
- id: black
args: [--safe, --quiet]
language_version: python3

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
rev: 7.3.0
hooks:
- id: flake8
exclude: docs
Expand Down
4 changes: 1 addition & 3 deletions src/pytest_selenium/drivers/saucelabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ def _video_html(session):
"url":"https://assets.saucelabs.com/jobs/{session}/video.flv",\
"provider":"streamer",\
"autoPlay":false,\
"autoBuffering":true}}]}}'.format(
session=session
)
"autoBuffering":true}}]}}'.format(session=session)

return (
f'<div id="player{session}" style="border:1px solid #e6e6e6; float:right; height:240px; margin-left:5px;'
Expand Down
32 changes: 10 additions & 22 deletions testing/test_browserstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@

@pytest.fixture
def testfile(testdir):
return testdir.makepyfile(
"""
return testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_pass(selenium): pass
"""
)
""")


def failure_with_output(testdir, *args, **kwargs):
Expand Down Expand Up @@ -107,18 +105,14 @@ def test_default_caps_in_jsonwp(monkeypatch, testdir):
variables = testdir.makefile(
".json", '{{"capabilities": {}}}'.format(json.dumps(capabilities))
)
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_bstack_capabilities(driver_kwargs):
assert driver_kwargs['options'].capabilities['browserstack.user'] == 'foo'
assert driver_kwargs['options'].capabilities['browserstack.key'] == 'bar'
assert driver_kwargs['options'].capabilities['name'] == '{0}'
""".format(
test_name
)
)
""".format(test_name))
testdir.quick_qa(
"--driver", "BrowserStack", "--variables", variables, file_test, passed=1
)
Expand All @@ -131,16 +125,14 @@ def test_default_caps_in_jsonwp_with_conflict(monkeypatch, testdir):
variables = testdir.makefile(
".json", '{{"capabilities": {}}}'.format(json.dumps(capabilities))
)
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_bstack_capabilities(driver_kwargs):
assert driver_kwargs['options'].capabilities['browserstack.user'] == 'foo'
assert driver_kwargs['options'].capabilities['browserstack.key'] == 'bar'
assert driver_kwargs['options'].capabilities['name'] == 'conflicting_name'
"""
)
""")
testdir.quick_qa(
"--driver", "BrowserStack", "--variables", variables, file_test, passed=1
)
Expand All @@ -153,8 +145,7 @@ def test_default_caps_in_W3C(monkeypatch, testdir):
variables = testdir.makefile(
".json", '{{"capabilities": {}}}'.format(json.dumps(capabilities))
)
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_bstack_capabilities(driver_kwargs):
Expand All @@ -163,8 +154,7 @@ def test_bstack_capabilities(driver_kwargs):
'accessKey': 'bar',
'sessionName': 'test_default_caps_in_W3C.test_bstack_capabilities'
}
"""
)
""")
testdir.quick_qa(
"--driver", "BrowserStack", "--variables", variables, file_test, passed=1
)
Expand All @@ -180,8 +170,7 @@ def test_default_caps_in_W3C_with_conflict(monkeypatch, testdir):
variables = testdir.makefile(
".json", '{{"capabilities": {}}}'.format(json.dumps(capabilities))
)
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_bstack_capabilities(driver_kwargs):
Expand All @@ -190,8 +179,7 @@ def test_bstack_capabilities(driver_kwargs):
'accessKey': 'bar',
'sessionName': 'conflicting_name'
}
"""
)
""")
testdir.quick_qa(
"--driver", "BrowserStack", "--variables", variables, file_test, passed=1
)
26 changes: 8 additions & 18 deletions testing/test_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@

@pytest.fixture
def testfile(testdir):
return testdir.makepyfile(
"""
return testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_capabilities(capabilities):
assert capabilities['foo'] == 'bar'
"""
)
""")


def test_command_line(testfile, testdir):
Expand All @@ -36,43 +34,35 @@ def test_file_remote(testdir):
variables = testdir.makefile(
".json", '{{"capabilities": {}}}'.format(json.dumps(capabilities))
)
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_capabilities(session_capabilities, capabilities):
assert session_capabilities['{0}']['args'] == ['foo']
assert capabilities['{0}']['args'] == ['foo']
""".format(
key
)
)
""".format(key))
testdir.quick_qa(
"--driver", "Remote", "--variables", variables, file_test, passed=1
)


def test_fixture(testfile, testdir):
testdir.makeconftest(
"""
testdir.makeconftest("""
import pytest
@pytest.fixture(scope='session')
def capabilities():
return {'foo': 'bar'}
"""
)
""")
testdir.quick_qa(testfile, passed=1)


def test_mark(testdir):
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
@pytest.mark.capabilities(foo='bar')
def test_capabilities(session_capabilities, capabilities):
assert 'foo' not in session_capabilities
assert capabilities['foo'] == 'bar'
"""
)
""")
testdir.quick_qa(file_test, passed=1)
18 changes: 6 additions & 12 deletions testing/test_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@

@pytest.mark.chrome
def test_launch(testdir):
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_pass(webtext):
assert webtext == u'Success!'
"""
)
""")
testdir.quick_qa(
"--driver",
"Remote",
Expand All @@ -32,8 +30,7 @@ def test_pass(webtext):

@pytest.mark.chrome
def test_options(testdir):
testdir.makepyfile(
"""
testdir.makepyfile("""
import pytest
@pytest.fixture
def chrome_options(chrome_options):
Expand All @@ -42,8 +39,7 @@ def chrome_options(chrome_options):

@pytest.mark.nondestructive
def test_pass(selenium): pass
"""
)
""")
reprec = testdir.inline_run(
"--driver", "Remote", "--capability", "browserName", "chrome"
)
Expand All @@ -56,8 +52,7 @@ def test_pass(selenium): pass
@pytest.mark.xfail(reason="Remote driver currently doesn't support logs")
@pytest.mark.chrome
def test_args(testdir):
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.fixture
def driver_log():
Expand All @@ -69,8 +64,7 @@ def driver_args():

@pytest.mark.nondestructive
def test_pass(selenium): pass
"""
)
""")
testdir.quick_qa(
"--driver",
"Remote",
Expand Down
6 changes: 2 additions & 4 deletions testing/test_crossbrowsertesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@

@pytest.fixture
def testfile(testdir):
return testdir.makepyfile(
"""
return testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_pass(selenium): pass
"""
)
""")


def failure_with_output(testdir, *args, **kwargs):
Expand Down
12 changes: 4 additions & 8 deletions testing/test_destructive.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ def test_skip_destructive_when_sensitive_env(testdir, monkeypatch):


def test_run_non_destructive_by_default(testdir):
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_pass(): pass
"""
)
""")
testdir.quick_qa(file_test, passed=1)


Expand All @@ -69,12 +67,10 @@ def test_run_destructive_when_not_sensitive_env(testdir, monkeypatch):


def test_run_destructive_and_non_destructive_when_not_sensitive(testdir):
file_test = testdir.makepyfile(
"""
file_test = testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_pass1(): pass
def test_pass2(): pass
"""
)
""")
testdir.quick_qa("--sensitive-url", "foo", file_test, passed=2)
Loading
Loading