Skip to content

Commit bac6c97

Browse files
committed
format
1 parent 92bf300 commit bac6c97

File tree

4 files changed

+21
-57
lines changed

4 files changed

+21
-57
lines changed

.github/workflows/smoke.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
pipenv install;
2828
- name: Run Smoke Tests in Win
2929
run: |
30-
pipenv run pytest --fx-executable ./firefox/firefox -s -n 4 tests/security_and_privacy
30+
pipenv run pytest --fx-executable ./firefox/firefox -n 4 .
3131
$env:TEST_EXIT_CODE = $LASTEXITCODE
3232
mv artifacts artifacts-win || true
3333
exit $env:TEST_EXIT_CODE
@@ -58,7 +58,7 @@ jobs:
5858
pipenv install;
5959
- name: Run Smoke Tests in MacOS
6060
run: |
61-
pipenv run pytest --fx-executable ./firefox/firefox -s -n 4 tests/security_and_privacy || TEST_EXIT_CODE=$?
61+
pipenv run pytest --fx-executable ./firefox/firefox -s -n 4 . || TEST_EXIT_CODE=$?
6262
mv artifacts artifacts-mac || true
6363
exit $TEST_EXIT_CODE
6464
- name: Upload artifacts

conftest.py

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import os
44
import platform
55
import re
6-
import sys
76
from typing import Callable, List, Tuple
87

98
import pytest
@@ -19,18 +18,10 @@ def screenshot_content(driver: Firefox, opt_ci: bool, test_name: str) -> None:
1918
"""
2019
Screenshots the current browser, saves with appropriate test name and date for reference
2120
"""
22-
artifacts_loc = "artifacts" if opt_ci else ""
2321
current_time = str(datetime.datetime.now())
2422
current_time = re.sub(r"[^\w_. -]", "_", current_time)
2523
filename = f"{test_name}_{current_time}_image"
26-
if not filename.endswith(".png"):
27-
filename = filename + ".png"
28-
artifacts_loc = ""
29-
if opt_ci:
30-
artifacts_loc = "artifacts"
31-
fullpath = os.path.join(artifacts_loc, filename)
32-
driver.save_screenshot(fullpath)
33-
return
24+
_screenshot(filename, driver, opt_ci)
3425

3526

3627
def log_content(opt_ci: bool, driver: Firefox, test_name: str) -> None:
@@ -67,10 +58,9 @@ def pytest_exception_interact(node, call, report):
6758
if report.failed:
6859
try:
6960
test_name = node.name
70-
logging.info(f"Handling exception for test: {test_name}")
71-
print(
72-
f"NODE LOGS HERE {node.funcargs}\n THE FAILED TEST: {test_name}",
73-
file=sys.stderr,
61+
logging.error(f"Handling exception for test: {test_name}")
62+
logging.error(
63+
f"NODE LOGS HERE {node.funcargs}\n THE FAILED TEST: {test_name}"
7464
)
7565
driver = node.funcargs.get("driver")
7666
opt_ci = node.funcargs.get("opt_ci")
@@ -127,6 +117,17 @@ def pytest_addoption(parser):
127117
)
128118

129119

120+
def _screenshot(filename: str, driver: Firefox, opt_ci: bool):
121+
if not filename.endswith(".png"):
122+
filename = filename + ".png"
123+
artifacts_loc = ""
124+
if opt_ci:
125+
artifacts_loc = "artifacts"
126+
fullpath = os.path.join(artifacts_loc, filename)
127+
driver.save_screenshot(fullpath)
128+
return fullpath
129+
130+
130131
@pytest.fixture()
131132
def opt_headless(request):
132133
return request.config.getoption("--run-headless")
@@ -267,20 +268,10 @@ def screenshot(driver: webdriver.Firefox, opt_ci: bool) -> Callable:
267268
Factory fixture that returns a screenshot function.
268269
"""
269270

270-
def _screenshot(filename: str) -> str:
271-
"""
272-
Given a short filename, save a screenshot and return the image's full path.
273-
"""
274-
if not filename.endswith(".png"):
275-
filename = filename + ".png"
276-
artifacts_loc = ""
277-
if opt_ci:
278-
artifacts_loc = "artifacts"
279-
fullpath = os.path.join(artifacts_loc, filename)
280-
driver.save_screenshot(fullpath)
281-
return fullpath
271+
def screenshot_wrapper(filename: str) -> str:
272+
return _screenshot(filename, driver, opt_ci)
282273

283-
return _screenshot
274+
return screenshot_wrapper
284275

285276

286277
@pytest.fixture()
@@ -296,28 +287,3 @@ def faker_seed():
296287
@pytest.fixture(scope="session")
297288
def fillable_pdf_url():
298289
return "https://www.uscis.gov/sites/default/files/document/forms/i-9.pdf"
299-
300-
301-
def log_page_content(driver: webdriver.Firefox, opt_ci: bool):
302-
"""
303-
Function that saves the html content into the artifacts on a failed test
304-
"""
305-
306-
def _log_page_content(opt_ci: bool):
307-
artifacts_loc = "artifacts" if opt_ci else ""
308-
fullpath_chrome = os.path.join(artifacts_loc, "page_source_chrome.html")
309-
fullpath_content = os.path.join(artifacts_loc, "page_source_content.html")
310-
311-
# Save Chrome context page source
312-
with open(fullpath_chrome, "w") as fh:
313-
driver.switch_to.context(driver.CONTEXT_CHROME)
314-
output_contents = driver.page_source.replace("><", ">\n<")
315-
fh.write(output_contents)
316-
317-
# Save Content context page source
318-
with open(fullpath_content, "w") as fh:
319-
driver.switch_to.context(driver.CONTEXT_CONTENT)
320-
output_contents = driver.page_source.replace("><", ">\n<")
321-
fh.write(output_contents)
322-
323-
return _log_page_content(opt_ci)

taskcluster/kinds/run-smoke-tests/kind.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tasks:
3131
./collect_executables.sh;
3232
mv ./ci_pyproject.toml ./pyproject.toml;
3333
pipenv install;
34-
pipenv run pytest --fx-executable ./firefox/firefox -s -n 4 tests/security_and_privacy
34+
pipenv run pytest --fx-executable ./firefox/firefox -s -n 4 .
3535
notify:
3636
recipients:
3737
- type: slack-channel

tests/security_and_privacy/test_1.py

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)