mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-09-05 00:35:13 +00:00
Use triple double-quoted strings for docstrings.
This commit is contained in:
@@ -41,9 +41,9 @@ class AANoCleanupMetaClass(type):
|
||||
|
||||
@classmethod
|
||||
def keep_on_fail(cls, unittest_func):
|
||||
'''wrapping function for unittest testcases to detect failure
|
||||
"""wrapping function for unittest testcases to detect failure
|
||||
and leave behind test files in tearDown(); to be used as
|
||||
a decorator'''
|
||||
a decorator"""
|
||||
|
||||
def new_unittest_func(self):
|
||||
try:
|
||||
@@ -58,17 +58,17 @@ class AANoCleanupMetaClass(type):
|
||||
|
||||
|
||||
class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
|
||||
'''Stub class for use by test scripts'''
|
||||
"""Stub class for use by test scripts"""
|
||||
debug = False
|
||||
do_cleanup = True
|
||||
|
||||
def run_cmd_check(self, command, input=None, stderr=subprocess.STDOUT, stdout=subprocess.PIPE,
|
||||
stdin=None, timeout=120, expected_rc=0, expected_string=None):
|
||||
'''Wrapper around run_cmd that checks the rc code against
|
||||
"""Wrapper around run_cmd that checks the rc code against
|
||||
expected_rc and for expected strings in the output if
|
||||
passed. The valgrind tests generally don't care what the
|
||||
rc is as long as it's not a specific set of return codes,
|
||||
so can't push the check directly into run_cmd().'''
|
||||
so can't push the check directly into run_cmd()."""
|
||||
rc, report = self.run_cmd(command, input, stderr, stdout, stdin, timeout)
|
||||
self.assertEqual(rc, expected_rc, "Got return code %d, expected %d\nCommand run: %s\nOutput: %s" % (rc, expected_rc, (' '.join(command)), report))
|
||||
if expected_string:
|
||||
@@ -77,8 +77,8 @@ class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
|
||||
|
||||
def run_cmd(self, command, input=None, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stdin=None, timeout=120):
|
||||
'''Try to execute given command (array) and return its stdout, or
|
||||
return a textual error if it failed.'''
|
||||
"""Try to execute given command (array) and return its stdout, or
|
||||
return a textual error if it failed."""
|
||||
|
||||
if self.debug:
|
||||
print('\n===> Running command: \'%s\'' % (' '.join(command)))
|
||||
@@ -90,7 +90,7 @@ class AATestTemplate(unittest.TestCase, metaclass=AANoCleanupMetaClass):
|
||||
|
||||
def _run_cmd(self, command, input=None, stderr=subprocess.PIPE, stdout=subprocess.PIPE,
|
||||
stdin=None, timeout=120):
|
||||
'''Try to execute given command (array) and return its rc, stdout, and stderr as a tuple'''
|
||||
"""Try to execute given command (array) and return its rc, stdout, and stderr as a tuple"""
|
||||
|
||||
try:
|
||||
sp = subprocess.Popen(command, stdin=stdin, stdout=stdout, stderr=stderr,
|
||||
@@ -143,7 +143,7 @@ class TimeoutFunction:
|
||||
|
||||
|
||||
def filesystem_time_resolution():
|
||||
'''detect whether the filesystem stores subsecond timestamps'''
|
||||
"""detect whether the filesystem stores subsecond timestamps"""
|
||||
|
||||
default_diff = 0.1
|
||||
result = (True, default_diff)
|
||||
@@ -198,7 +198,7 @@ def touch(path):
|
||||
|
||||
|
||||
def write_file(directory, file, contents):
|
||||
'''construct path, write contents to it, and return the constructed path'''
|
||||
"""construct path, write contents to it, and return the constructed path"""
|
||||
path = os.path.join(directory, file)
|
||||
with open(path, 'w+') as f:
|
||||
f.write(contents)
|
||||
|
Reference in New Issue
Block a user