diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-09-20 09:54:49 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-09-21 20:16:37 -0400 |
commit | 9e0d797ba7a14ffc4611655008f926f84e896918 (patch) | |
tree | 03947a9cfce0aad17bcf845ae4fe4839f13912c9 /systemd/test | |
parent | 52119523482430f762f7c8d75161f714b7ef3670 (diff) | |
download | python-systemd-9e0d797ba7a14ffc4611655008f926f84e896918.tar.gz |
journal: convert seek_realtime argument to microseconds
This somewhat breaks backwards compatibility, but not for the
previously documented arguments: floats are now interpreted
differently, but ints and datetime.datetime objects are interpreted
the same as before. But the documentation clearly stated that only
ints and datetime.datetime objects were allowed.
This makes seek_realtime match seek_monotonic and other functions
which take time and follows the principle of least surprise.
Fixes #21.
Diffstat (limited to 'systemd/test')
-rw-r--r-- | systemd/test/test_journal.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/systemd/test/test_journal.py b/systemd/test/test_journal.py index 4acd7fe..0902183 100644 --- a/systemd/test/test_journal.py +++ b/systemd/test/test_journal.py @@ -1,8 +1,11 @@ -import logging import contextlib -import uuid +import datetime import errno +import logging import os +import time +import uuid + from systemd import journal, id128 import pytest @@ -176,3 +179,14 @@ def test_reader_convert_entry(tmpdir): 'y1' : b'\200\200', 'x2' : ['YYY', 'YYY'], 'y2' : [b'\200\200', b'\200\201']} + +def test_seek_realtime(tmpdir): + j = journal.Reader(path=tmpdir.strpath) + + now = time.time() + j.seek_realtime(now) + + j.seek_realtime(12345) + + long_ago = datetime.datetime(1970, 5, 4) + j.seek_realtime(long_ago) |