Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_03(self):
"test CheckLogSize()"
stde = os.path.join(self.tmpdir, "stderr")
stdo = os.path.join(self.tmpdir, "stdout")
with open(stde, "w") as out_fp:
out_fp.write("test\n")
with open(stdo, "w") as out_fp:
out_fp.write("test\n")
checker = CheckLogSize(1, stde, stdo)
self.assertTrue(checker.check())
with open(self.tmpfn, "wb") as log_fp:
checker.dump_log(log_fp)
self.assertGreater(log_fp.tell(), 1)
checker = CheckLogSize(12, stde, stdo)
self.assertFalse(checker.check())
with open(self.tmpfn, "wb") as log_fp:
checker.dump_log(log_fp)
self.assertEqual(log_fp.tell(), 0)
def test_03(self):
"test CheckLogSize()"
stde = os.path.join(self.tmpdir, "stderr")
stdo = os.path.join(self.tmpdir, "stdout")
with open(stde, "w") as out_fp:
out_fp.write("test\n")
with open(stdo, "w") as out_fp:
out_fp.write("test\n")
checker = CheckLogSize(1, stde, stdo)
self.assertTrue(checker.check())
with open(self.tmpfn, "wb") as log_fp:
checker.dump_log(log_fp)
self.assertGreater(log_fp.tell(), 1)
checker = CheckLogSize(12, stde, stdo)
self.assertFalse(checker.check())
with open(self.tmpfn, "wb") as log_fp:
checker.dump_log(log_fp)
self.assertEqual(log_fp.tell(), 0)
cmd,
bufsize=0, # unbuffered (for log scanners)
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP if is_windows else 0,
env=prepare_environment(self._last_bin_path, sanitizer_logs, env_mod=env_mod),
shell=False,
stderr=stderr,
stdout=self._logs.get_fp("stdout"))
log.debug("launched firefox with pid: %d", self._proc.pid)
bootstrapper.wait(self.is_healthy, timeout=launch_timeout, url=location)
finally:
bootstrapper.close()
if prefs_js is not None and os.path.isfile(os.path.join(self.profile, "Invalidprefs.js")):
raise InvalidPrefs("%r is invalid" % prefs_js)
if log_limit:
self._checks.append(CheckLogSize(
log_limit,
self._logs.get_fp("stderr").name,
self._logs.get_fp("stdout").name))
if memory_limit:
self._checks.append(CheckMemoryUsage(self.get_pid(), memory_limit))
if self._abort_tokens:
self._checks.append(CheckLogContents(
[self._logs.get_fp("stderr").name, self._logs.get_fp("stdout").name],
self._abort_tokens))
self._launches += 1
def __init__(self, limit, stderr_file, stdout_file):
super(CheckLogSize, self).__init__()
self.limit = limit
self.stderr_file = stderr_file
self.stdout_file = stdout_file