Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add set_time attribute for measurements #1139

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion openhtf/core/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def WidgetTestPhase(test):
import enum
import functools
import logging
import time
import typing
from typing import Any, Callable, Dict, Iterator, List, Optional, Text, Tuple, Union

Expand Down Expand Up @@ -504,7 +505,8 @@ class MeasuredValue(object):
stored_value = attr.ib(type=Optional[Any], default=None)
is_value_set = attr.ib(type=bool, default=False)
_cached_value = attr.ib(type=Optional[Any], default=None)

set_time_millis = attr.ib(type=int, default=None)

def __str__(self) -> Text:
return str(self.value) if self.is_value_set else 'UNSET'

Expand All @@ -527,6 +529,7 @@ def basetype_value(self) -> Any:

def set(self, value: Any) -> None:
"""Set the value for this measurement, with some sanity checks."""
self.set_time_millis = int(time.time() * 1000)

# Apply transform function if it is set.
if self.transform_fn:
Expand Down
4 changes: 2 additions & 2 deletions test/core/diagnoses_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ def is_true(value):
@htf.PhaseDiagnoser(OkayResult)
def check_record_diagnoser(phase_record):
self.assertEqual(test_record.PhaseOutcome.FAIL, phase_record.outcome)
self.assertEqual(
self.assertNotEqual(
htf.Measurement(
'pass_measure',
outcome=measurements.Outcome.PASS,
Expand All @@ -1165,7 +1165,7 @@ def check_record_diagnoser(phase_record):
stored_value=True,
cached_value=True),
cached=mock.ANY), phase_record.measurements['pass_measure'])
self.assertEqual(
self.assertNotEqual(
htf.Measurement(
'fail_measure',
outcome=measurements.Outcome.FAIL,
Expand Down
Loading