Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mhaoli committed Dec 3, 2024
1 parent 3985e78 commit 74e4363
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
20 changes: 14 additions & 6 deletions mobly/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,32 +729,40 @@ def summary_dict(self):


class SuiteInfoRecord:
"""A record representing the suite info in test summary.
"""A record representing the test suite info in test summary.
Attributes:
suite_class: str, the class name of the test suite class.
test_suite_class: str, the class name of the test suite class.
begin_time: int, epoch timestamp of when the suite started.
end_time: int, epoch timestamp of when the suite ended.
"""

KEY_SUITE_CLASS = 'Suite Class'
KEY_TEST_SUITE_CLASS = 'Test Suite Class'
KEY_BEGIN_TIME = TestResultEnums.RECORD_BEGIN_TIME
KEY_END_TIME = TestResultEnums.RECORD_END_TIME

def __init__(self, suite_class):
self.suite_class = suite_class
def __init__(self, test_suite_class):
self.test_suite_class = test_suite_class
self.begin_time = None
self.end_time = None

def suite_begin(self):
"""Call this when the suite begins execution.
Sets the begin_time of this record.
"""
self.begin_time = utils.get_current_epoch_time()

def suite_end(self):
"""Call this when the suite ends execution.
Sets the end_time of this record.
"""
self.end_time = utils.get_current_epoch_time()

def to_dict(self):
result = {}
result[self.KEY_SUITE_CLASS] = self.suite_class
result[self.KEY_TEST_SUITE_CLASS] = self.test_suite_class
result[self.KEY_BEGIN_TIME] = self.begin_time
result[self.KEY_END_TIME] = self.end_time
return result
Expand Down
2 changes: 1 addition & 1 deletion mobly/suite_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def run_suite_class(argv=None):
suite = suite_class(runner, config)
console_level = logging.DEBUG if cli_args.verbose else logging.INFO
ok = False
suite_record = records.SuiteInfoRecord(suite_class=suite_class.__name__)
suite_record = records.SuiteInfoRecord(test_suite_class=suite_class.__name__)
with runner.mobly_logger(console_level=console_level) as log_path:
try:
suite.setup_suite(config.copy())
Expand Down
4 changes: 2 additions & 2 deletions tests/mobly/records_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,14 +544,14 @@ def test_uid_helper():

def test_convert_suite_info_record_to_dict(self):
suite_class_name = 'FakeTestSuite'
record = records.SuiteInfoRecord(suite_class=suite_class_name)
record = records.SuiteInfoRecord(test_suite_class=suite_class_name)
record.suite_begin()
record.suite_end()

result = record.to_dict()

self.assertIn(
(records.SuiteInfoRecord.KEY_SUITE_CLASS, suite_class_name),
(records.SuiteInfoRecord.KEY_TEST_SUITE_CLASS, suite_class_name),
result.items(),
)
self.assertIn(records.SuiteInfoRecord.KEY_BEGIN_TIME, result)
Expand Down
2 changes: 1 addition & 1 deletion tests/mobly/suite_runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def teardown_suite(self):
def test_run_suite_class_records_suite_class_name(self, mock_time, _):
tmp_file_path = self._gen_tmp_config_file()
mock_cli_args = ['test_binary', f'--config={tmp_file_path}']
expected_record = records.SuiteInfoRecord(suite_class='FakeTestSuite')
expected_record = records.SuiteInfoRecord(test_suite_class='FakeTestSuite')
expected_record.suite_begin()
expected_record.suite_end()
expected_summary_entry = expected_record.to_dict()
Expand Down

0 comments on commit 74e4363

Please sign in to comment.