summaryrefslogtreecommitdiff
path: root/systemd/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-08-16 10:34:10 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-08-16 11:03:09 +0200
commit872ce304a07bb4c1b4fc06b7bfbd9220652c3793 (patch)
tree1f80e498266202a21bfaaa3b8e07f0ea36875d74 /systemd/test
parent6320847472657fc2b4f98dd5bfeb4c826ed68a06 (diff)
downloadpython-systemd-872ce304a07bb4c1b4fc06b7bfbd9220652c3793.tar.gz
journal: fix compatibility with python2
This is a lazy workaround: 4c9a241949067fc8d55f3ea12170ad364bd8b18d is amended to do nothing on python2, so we have the same issue that was present before. This allows the code to execute, and hopefully almost nobody is using python2 code anyway. f868a56b935b6152d611b22f7a5538f14dafb194 is amended in the same way. For python2 code we have the same lack of timezone-awareness as before. This allows the tests to pass under python 2.7.
Diffstat (limited to 'systemd/test')
-rw-r--r--systemd/test/test_journal.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/systemd/test/test_journal.py b/systemd/test/test_journal.py
index e6761ca..98c7e87 100644
--- a/systemd/test/test_journal.py
+++ b/systemd/test/test_journal.py
@@ -6,6 +6,7 @@ import logging
import os
import time
import uuid
+import sys
import traceback as _traceback
from systemd import journal, id128
@@ -294,13 +295,16 @@ def test_reader_convert_timestamps(tmpdir):
j = journal.Reader(path=tmpdir.strpath)
val = j._convert_field('_SOURCE_REALTIME_TIMESTAMP', 1641651559324187)
- assert val.tzinfo is not None
+ if sys.version_info >= (3,):
+ assert val.tzinfo is not None
val = j._convert_field('__REALTIME_TIMESTAMP', 1641651559324187)
- assert val.tzinfo is not None
+ if sys.version_info >= (3,):
+ assert val.tzinfo is not None
val = j._convert_field('COREDUMP_TIMESTAMP', 1641651559324187)
- assert val.tzinfo is not None
+ if sys.version_info >= (3,):
+ assert val.tzinfo is not None
def test_seek_realtime(tmpdir):
j = journal.Reader(path=tmpdir.strpath)