[apparmor] [patch] Beautify RlimitRule coverage report

Seth Arnold seth.arnold at canonical.com
Tue Nov 8 19:40:13 UTC 2016


On Tue, Nov 08, 2016 at 05:43:28PM +0100, Christian Boltz wrote:
> Hello,
> 
> some conditions in RlimitRule can never be hit under normal
> circumstances, so this patch adds some "pragma: no cover" and
> "pragma: no branch" comments to beautify the coverage report.
> 
> 
> [ 01-rlimit-coverage-pragma.diff ]

Man just how wide -is- your terminal? :)

Acked-by: Seth Arnold <seth.arnold at canonical.com>

Thanks

> 
> === modified file ./utils/apparmor/rule/rlimit.py
> --- utils/apparmor/rule/rlimit.py       2016-10-01 20:33:23.421684000 +0200
> +++ utils/apparmor/rule/rlimit.py       2016-11-08 17:29:36.237899601 +0100
> @@ -96,7 +96,7 @@
>                  else:
>                      self.value_as_int = self.time_to_int(value, 'seconds')
>  
> -            elif rlimit in rlimit_nice:
> +            elif rlimit in rlimit_nice:  # pragma: no branch - "if rlimit in rlimit_all:" above avoids the need for an "else:" branch
>                  if not RE_NICE.match(value):
>                      raise AppArmorException('Invalid value or unit in rlimit %s %s rule' % (rlimit, value))
>                  self.value_as_int = 0 - int(value)  # lower numbers mean a higher limit for nice
> @@ -123,7 +123,7 @@
>          if matches.group('rlimit'):
>              rlimit = strip_quotes(matches.group('rlimit'))
>          else:
> -            raise AppArmorException(_("Invalid rlimit rule '%s' - keyword missing") % raw_rule)
> +            raise AppArmorException(_("Invalid rlimit rule '%s' - keyword missing") % raw_rule)  # pragma: no cover - would need breaking the regex
>  
>          if matches.group('value'):
>              if matches.group('value') == 'infinity':
> @@ -131,7 +131,7 @@
>              else:
>                  value = strip_quotes(matches.group('value'))
>          else:
> -            raise AppArmorException(_("Invalid rlimit rule '%s' - value missing") % raw_rule)
> +            raise AppArmorException(_("Invalid rlimit rule '%s' - value missing") % raw_rule)  # pragma: no cover - would need breaking the regex
>  
>          return RlimitRule(rlimit, value,
>                             comment=comment)
> 
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20161108/1e418dba/attachment-0001.pgp>


More information about the AppArmor mailing list