From def9fd0c22e43e437f867eb1f4bafc7c4a68898b Mon Sep 17 00:00:00 2001 From: Petr Lautrbach Date: Tue, 18 Jan 2022 11:59:40 +0100 Subject: [PATCH] util.py: Improve doctest tests Usage: # python3 -m doctest -v src/setroubleshoot/util.py --- src/setroubleshoot/util.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/setroubleshoot/util.py b/src/setroubleshoot/util.py index 02c4f752e690..de10c7319138 100755 --- a/src/setroubleshoot/util.py +++ b/src/setroubleshoot/util.py @@ -321,7 +321,7 @@ def default_date_text(date): def get_standard_directories(): """ ->>> get_standard_directories() +>>> get_standard_directories() # doctest: +ELLIPSIS [...'/bin'...] """ lst = [] @@ -347,8 +347,8 @@ def get_rpm_nvr_from_header(hdr): def get_package_nvr_by_name(name): """ ->>> get_package_nvr_by_name("coreutils") -'coreutils-8.30-3+b1:amd64' +>>> get_package_nvr_by_name("coreutils")[0:9] +'coreutils' """ if name is None: return None @@ -369,8 +369,8 @@ def get_package_nvr_by_name(name): def get_package_nvr_by_file_path(name): """ ->>> get_package_nvr_by_file_path("/bin/ls") -'coreutils-8.30-3+b1:amd64' +>>> get_package_nvr_by_file_path("/bin/ls")[0:9] +'coreutils' """ if name is None: return None @@ -424,11 +424,11 @@ Finds an SELinux module which defines given SELinux type ##### usage ->>> get_rpm_nvr_by_type("sshd_t") -'selinux-policy-... +>>> get_rpm_nvr_by_type("sshd_t")[0:14] +'selinux-policy' ->>> get_rpm_nvr_by_type("mysqld_log_t") -'mysql-selinux-... +>>> get_rpm_nvr_by_type("mysqld_log_t")[0:13] +'mysql-selinux' """ @@ -511,14 +511,14 @@ Finds an SELinux module which defines given SELinux context ##### usage ->>> get_rpm_nvr_by_scontext("system_u:system_r:syslogd_t:s0") -'selinux-policy-... +>>> get_rpm_nvr_by_scontext("system_u:system_r:syslogd_t:s0")[0:14] +'selinux-policy' ->>> get_rpm_nvr_by_scontext("system_u:system_r:mysqld_log_t:s0") -'mysql-selinux-... +>>> get_rpm_nvr_by_scontext("system_u:system_r:mysqld_log_t:s0")[0:13] +'mysql-selinux' ->>> get_rpm_nvr_by_scontext("system_u:system_r:timedatex_t:s0", use_dbus=True) -'selinux-policy-... +>>> get_rpm_nvr_by_scontext("system_u:system_r:timedatex_t:s0", use_dbus=True)[0:14] +'selinux-policy' """ if use_dbus: @@ -542,6 +542,8 @@ def get_rpm_source_package(name): >>> get_rpm_source_package("selinux-policy-targeted") 'selinux-policy' + >>> get_rpm_source_package("selinux-policy-targeted-35.8-1.fc35.noarch") + 'selinux-policy' """ if name is None: return None -- 2.34.1