2
This module provides a class to easily store test results
4
from time import strftime
5
from shutil import move
9
from .utils import safe_make_directory
11
class ResultDict(dict):
13
Dictionary-like class to store test case results
15
def __setitem__(self, key, value):
17
Set value as a one element list using key
19
dict.__setitem__(self, key, [value])
22
def append(self, key, value):
24
Append a result using key
26
values = self.get(key, None)
33
def append_screenshot(self, screenshot_file=None):
35
Take screenshot and append the filename to screenshot results
37
_logFile = "%s/screenshot-%s.png" % (globals.SCREENSHOTS_SHARE,
38
strftime ("%m-%d-%Y-%H-%M-%s"))
39
safe_make_directory(globals.SCREENSHOTS_SHARE)
40
if not screenshot_file:
41
ldtputils.imagecapture(outFile = _logFile)
43
move(screenshot_file, _logFile)
44
self.append('screenshot', _logFile)