File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 7676 # Avoid importing the systemd module from the git repository
7777 cd /
7878 python3 -c 'from systemd import journal; print(journal.__version__)'
79- # Initialize /etc/machine-id if it's empty to make the tests happy
80- [[ ! -s /etc/machine-id ]] && systemd-id128 new >/etc/machine-id
8179 pytest -v --pyargs systemd
Original file line number Diff line number Diff line change 66from systemd import id128
77
88@contextlib .contextmanager
9- def skip_oserror (code ):
9+ def skip_oserror (* errnos ):
1010 try :
1111 yield
1212 except (OSError , IOError ) as e :
13- if e .errno == code :
13+ if e .errno in errnos :
1414 pytest .skip ()
1515 raise
1616
@@ -21,15 +21,18 @@ def test_randomize():
2121 assert u1 != u2
2222
2323def test_get_machine ():
24- u1 = id128 .get_machine ()
24+ # yikes, python2 doesn't know ENOMEDIUM
25+ with skip_oserror (errno .ENOENT , errno .ENOSYS , 123 ):
26+ u1 = id128 .get_machine ()
27+
2528 u2 = id128 .get_machine ()
2629 assert u1 == u2
2730
2831def test_get_machine_app_specific ():
2932 a1 = uuid .uuid1 ()
3033 a2 = uuid .uuid1 ()
3134
32- with skip_oserror (errno .ENOSYS ):
35+ with skip_oserror (errno .ENOENT , errno . ENOSYS , 123 ):
3336 u1 = id128 .get_machine_app_specific (a1 )
3437
3538 u2 = id128 .get_machine_app_specific (a2 )
Original file line number Diff line number Diff line change @@ -233,7 +233,11 @@ def test_reader_this_boot(tmpdir):
233233def test_reader_this_machine (tmpdir ):
234234 j = journal .Reader (path = tmpdir .strpath )
235235 with j :
236- j .this_machine ()
236+ try :
237+ j .this_machine ()
238+ except OSError :
239+ pass
240+
237241 j .this_machine (TEST_MID )
238242 j .this_machine (TEST_MID .hex )
239243
You can’t perform that action at this time.
0 commit comments