Server IP : 127.0.0.2 / Your IP : 3.21.35.63 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/lib/python3/dist-packages/systemd/test/ |
Upload File : |
import logging import uuid from systemd import journal, id128 import pytest TEST_MID = uuid.UUID('8441372f8dca4ca98694a6091fd8519f') def test_priorities(): p = journal.JournalHandler.mapPriority assert p(logging.NOTSET) == journal.LOG_DEBUG assert p(logging.DEBUG) == journal.LOG_DEBUG assert p(logging.DEBUG - 1) == journal.LOG_DEBUG assert p(logging.DEBUG + 1) == journal.LOG_INFO assert p(logging.INFO - 1) == journal.LOG_INFO assert p(logging.INFO) == journal.LOG_INFO assert p(logging.INFO + 1) == journal.LOG_WARNING assert p(logging.WARN - 1) == journal.LOG_WARNING assert p(logging.WARN) == journal.LOG_WARNING assert p(logging.WARN + 1) == journal.LOG_ERR assert p(logging.ERROR - 1) == journal.LOG_ERR assert p(logging.ERROR) == journal.LOG_ERR assert p(logging.ERROR + 1) == journal.LOG_CRIT assert p(logging.FATAL) == journal.LOG_CRIT assert p(logging.CRITICAL) == journal.LOG_CRIT assert p(logging.CRITICAL + 1) == journal.LOG_ALERT def test_journalhandler_init_exception(): kw = {' X ':3} with pytest.raises(ValueError): journal.JournalHandler(**kw) def test_journalhandler_init(): kw = {'X':3, 'X3':4} journal.JournalHandler(logging.INFO, **kw) def test_reader_init_flags(): j1 = journal.Reader() j2 = journal.Reader(journal.LOCAL_ONLY) j3 = journal.Reader(journal.RUNTIME_ONLY) j4 = journal.Reader(journal.SYSTEM_ONLY) j5 = journal.Reader(journal.LOCAL_ONLY| journal.RUNTIME_ONLY| journal.SYSTEM_ONLY) j6 = journal.Reader(0) def test_reader_init_path(tmpdir): j = journal.Reader(path=tmpdir.strpath) with pytest.raises(ValueError): journal.Reader(journal.LOCAL_ONLY, path=tmpdir.strpath) def test_reader_as_cm(tmpdir): j = journal.Reader(path=tmpdir.strpath) with j: assert not j.closed assert j.closed # make sure that operations on the Reader fail with pytest.raises(OSError): next(j) def test_reader_messageid_match(tmpdir): j = journal.Reader(path=tmpdir.strpath) with j: j.messageid_match(id128.SD_MESSAGE_JOURNAL_START) j.messageid_match(id128.SD_MESSAGE_JOURNAL_STOP.hex) def test_reader_this_boot(tmpdir): j = journal.Reader(path=tmpdir.strpath) with j: j.this_boot() j.this_boot(TEST_MID) j.this_boot(TEST_MID.hex) def test_reader_this_machine(tmpdir): j = journal.Reader(path=tmpdir.strpath) with j: j.this_machine() j.this_machine(TEST_MID) j.this_machine(TEST_MID.hex) def test_reader_converters(tmpdir): converters = {'xxx' : lambda arg: 'yyy'} j = journal.Reader(path=tmpdir.strpath, converters=converters) val = j._convert_field('xxx', b'abc') assert val == 'yyy' val = j._convert_field('zzz', b'\200\200') assert val == b'\200\200' def test_reader_convert_entry(tmpdir): converters = {'x1' : lambda arg: 'yyy', 'x2' : lambda arg: 'YYY'} j = journal.Reader(path=tmpdir.strpath, converters=converters) val = j._convert_entry({'x1' : b'abc', 'y1' : b'\200\200', 'x2' : [b'abc', b'def'], 'y2' : [b'\200\200', b'\200\201']}) assert val == {'x1' : 'yyy', 'y1' : b'\200\200', 'x2' : ['YYY', 'YYY'], 'y2' : [b'\200\200', b'\200\201']}