-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathtest_crossbrowsertesting.py
More file actions
56 lines (41 loc) · 1.68 KB
/
test_crossbrowsertesting.py
File metadata and controls
56 lines (41 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from functools import partial
import os
import pytest
pytestmark = [pytest.mark.skip_selenium, pytest.mark.nondestructive]
@pytest.fixture
def testfile(testdir):
return testdir.makepyfile("""
import pytest
@pytest.mark.nondestructive
def test_pass(selenium): pass
""")
def failure_with_output(testdir, *args, **kwargs):
reprec = testdir.inline_run(*args, **kwargs)
passed, skipped, failed = reprec.listoutcomes()
assert len(failed) == 1
out = failed[0].longrepr.reprcrash.message
return out
@pytest.fixture
def failure(testdir, testfile, httpserver_base_url):
return partial(
failure_with_output,
testdir,
testfile,
httpserver_base_url,
"--driver",
"CrossBrowserTesting",
)
def test_missing_username(failure, monkeypatch, tmpdir):
monkeypatch.setattr(os.path, "expanduser", lambda p: str(tmpdir))
assert "CrossBrowserTesting username must be set" in failure()
def test_missing_access_key_env(failure, monkeypatch, tmpdir):
monkeypatch.setattr(os.path, "expanduser", lambda p: str(tmpdir))
monkeypatch.setenv("CROSSBROWSERTESTING_USERNAME", "foo")
assert "CrossBrowserTesting key must be set" in failure()
def test_missing_access_key_file(failure, monkeypatch, tmpdir):
monkeypatch.setattr(os.path, "expanduser", lambda p: str(tmpdir))
tmpdir.join(".crossbrowsertesting").write("[credentials]\nusername=foo")
assert "CrossBrowserTesting key must be set" in failure()