-# Copyright (c) 2020 Matthias Dellweg
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@summary: Ansible module for different test functions.
+
+@author: Matthias Dellweg
+ Frank Brehm
+@contact: frank@brehm-online.com
+@copyright: © 2020 Matthias Dellweg
+"""
import typing as t
from jinja2.runtime import Undefined
+# =============================================================================
def empty_test(value: t.Any) -> bool:
- """
- Check whether a value is false or an empty string, list or dict.
- """
+ """Check whether a value is false or an empty string, list or dict."""
if isinstance(value, Undefined):
return True
if isinstance(value, bool):
return not value
if value is None:
return True
- if value == "":
+ if value == '':
return True
if value == []:
return True
if value == {}:
return True
- if value == b"":
+ if value == b'':
return True
return False
+# =============================================================================
class TestModule:
+ """A test module object."""
+
+ # ------------------
def tests(self) -> t.Dict[str, t.Callable]:
+ """Return all usable test functions and methods from this module."""
return {
- "empty": empty_test,
+ 'empty': empty_test,
}
-# last line
+# vim: ts=4 et list