From 8aa0b72b671a3e7bc934b27042cde3302ae71cbb Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 12 Jul 2020 16:17:04 +0200 Subject: [PATCH] e2e: only save screenshots in CI --- e2e/utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e/utils.py b/e2e/utils.py index a78dc9e5b..9129e85a4 100644 --- a/e2e/utils.py +++ b/e2e/utils.py @@ -3,7 +3,7 @@ from functools import lru_cache from glob import glob from importlib.util import module_from_spec, spec_from_file_location from inspect import getmembers, isfunction -from os import makedirs +from os import environ, makedirs from time import time from Cryptodome.PublicKey import RSA @@ -58,9 +58,12 @@ class SeleniumTestCase(StaticLiveServerTestCase): ) def tearDown(self): - screenshot_file = f"selenium_screenshots/{self.__class__.__name__}_{time()}.png" - self.driver.save_screenshot(screenshot_file) - self.logger.warning("Saved screenshot", file=screenshot_file) + if "CI" in environ: + screenshot_file = ( + f"selenium_screenshots/{self.__class__.__name__}_{time()}.png" + ) + self.driver.save_screenshot(screenshot_file) + self.logger.warning("Saved screenshot", file=screenshot_file) for line in self.driver.get_log("browser"): self.logger.warning( line["message"], source=line["source"], level=line["level"]