Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BeyondEvil committed Jun 23, 2020
1 parent 9e4ef72 commit 4e085ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
8 changes: 6 additions & 2 deletions pytest_selenium/pytest_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ def _gather_logs(item, report, driver, summary, extra):

def _gather_driver_log(item, summary, extra):
pytest_html = item.config.pluginmanager.getplugin("html")
if hasattr(item.config, "_driver_log") and os.path.exists(item.config._driver_log):
if (
hasattr(item.config, "_driver_log")
and item.config._driver_log is not None
and os.path.exists(item.config._driver_log)
):
if pytest_html is not None:
with io.open(item.config._driver_log, "r", encoding="utf8") as f:
extra.append(pytest_html.extras.text(f.read(), "Driver Log"))
Expand All @@ -344,7 +348,7 @@ def _gather_driver_log(item, summary, extra):
def format_log(log):
timestamp_format = "%Y-%m-%d %H:%M:%S.%f"
entries = [
u"{0} {1[level]} - {1[message]}".format(
"{0} {1[level]} - {1[message]}".format(
datetime.utcfromtimestamp(entry["timestamp"] / 1000.0).strftime(
timestamp_format
),
Expand Down
25 changes: 0 additions & 25 deletions testing/test_crossbrowsertesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,3 @@ 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()


@pytest.mark.parametrize(
("username", "key"),
[
("CROSSBROWSERTESTING_USERNAME", "CROSSBROWSERTESTING_AUTH_KEY"),
("CROSSBROWSERTESTING_USR", "CROSSBROWSERTESTING_PSW"),
],
)
def test_invalid_credentials_env(failure, monkeypatch, tmpdir, username, key):
monkeypatch.setattr(os.path, "expanduser", lambda p: str(tmpdir))
monkeypatch.setenv(username, "foo")
monkeypatch.setenv(key, "bar")
out = failure("--capability", "browser_api_name", "FF46")
messages = ["missing auth", "basic auth failed"]
assert any(message in out for message in messages)


def test_invalid_credentials_file(failure, monkeypatch, tmpdir):
monkeypatch.setattr(os.path, "expanduser", lambda p: str(tmpdir))
config = tmpdir.join(".crossbrowsertesting")
config.write("[credentials]\nusername=foo\nkey=bar")
out = failure("--capability", "browser_api_name", "FF46")
messages = ["missing auth", "basic auth failed"]
assert any(message in out for message in messages)
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setenv =
deps =
pytest-localserver
pytest-xdist
commands = pytest -n auto -v -r a {posargs}
commands = pytest -n auto -v -r a --color=yes --html={envlogdir}/report.html --self-contained-html {posargs}

[testenv:docs]
basepython = python
Expand Down Expand Up @@ -43,3 +43,7 @@ markers =
skip_selenium
nondestructive
phantomjs
# TODO: Temporary hack until they fix
# https://github.com/pytest-dev/pytest/issues/6936
filterwarnings =
ignore:.*TerminalReporter.writer attribute is deprecated.*:pytest.PytestDeprecationWarning

0 comments on commit 4e085ed

Please sign in to comment.