Skip to content

Commit aefefcd

Browse files
committed
fix alignment of message timestamp printing
1 parent fd624bf commit aefefcd

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

can/message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def __init__(self, timestamp=0.0, is_remote_frame=False, extended_id=True,
6969
logger.warning("data link count was %d but it should be less than or equal to 8", self.dlc)
7070

7171
def __str__(self):
72-
field_strings = ["Timestamp: {0:15.6f}".format(self.timestamp)]
72+
field_strings = ["Timestamp: {0:>15.6f}".format(self.timestamp)]
7373
if self.id_type:
7474
# Extended arbitrationID
7575
arbitration_id_string = "ID: {0:08x}".format(self.arbitration_id)

test/logformats_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _test_writer_and_reader(test_case, writer_constructor, reader_constructor,
6666
original_comments = TEST_COMMENTS if check_comments else ()
6767

6868
# TODO: use https://docs.python.org/3/library/unittest.html#unittest.TestCase.subTest
69-
# once Python 2.7 gets dropped
69+
# once Python 2.7 support gets dropped
7070

7171
print("testing with path-like object and explicit stop() call")
7272
temp = tempfile.NamedTemporaryFile('w', delete=False)
@@ -85,8 +85,10 @@ def _test_writer_and_reader(test_case, writer_constructor, reader_constructor,
8585
use_context_manager=True, **kwargs)
8686

8787
print("testing with file-like object and explicit stop() call")
88+
# TODO
8889

8990
print("testing with file-like object and context manager")
91+
# TODO
9092

9193

9294
def _test_writer_and_reader_execute(test_case, writer_constructor, reader_constructor,
@@ -163,8 +165,8 @@ def _write_all(writer):
163165
# check everything except the timestamp
164166
if read != original:
165167
# check like this to print the whole message
166-
print("original message: {}".format(original))
167-
print("read message: {}".format(read))
168+
print("original message: {!r}".format(original))
169+
print("read message: {!r}".format(read))
168170
test_case.fail()
169171
# check the timestamp
170172
if round_timestamps:

0 commit comments

Comments
 (0)