tools/lib/python/unittest_helper.py
Source file repositories/reference/linux-study-clean/tools/lib/python/unittest_helper.py
File Facts
- System
- Linux kernel
- Corpus path
tools/lib/python/unittest_helper.py- Extension
.py- Size
- 11657 bytes
- Lines
- 364
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function print
Annotated Snippet
print(f"){COLORS['reset']}")
def flatten_suite(suite):
"""Flatten test suite hierarchy."""
tests = []
for item in suite:
if isinstance(item, unittest.TestSuite):
tests.extend(flatten_suite(item))
else:
tests.append(item)
return tests
class TestUnits:
"""
Helper class to set verbosity level.
This class discover test files, import its unittest classes and
executes the test on it.
"""
def parse_args(self):
"""Returns a parser for command line arguments."""
parser = argparse.ArgumentParser(description="Test runner with regex filtering")
parser.add_argument("-v", "--verbose", action="count", default=1)
parser.add_argument("-q", "--quiet", action="store_true")
parser.add_argument("-f", "--failfast", action="store_true")
parser.add_argument("-k", "--keyword",
help="Regex pattern to filter test methods")
return parser
def run(self, caller_file=None, pattern=None,
suite=None, parser=None, args=None, env=None):
"""
Execute all tests from the unity test file.
It contains several optional parameters:
``caller_file``:
- name of the file that contains test.
typical usage is to place __file__ at the caller test, e.g.::
if __name__ == "__main__":
TestUnits().run(__file__)
``pattern``:
- optional pattern to match multiple file names. Defaults
to basename of ``caller_file``.
``suite``:
- an unittest suite initialized by the caller using
``unittest.TestLoader().discover()``.
``parser``:
- an argparse parser. If not defined, this helper will create
one.
``args``:
- an ``argparse.Namespace`` data filled by the caller.
``env``:
- environment variables that will be passed to the test suite
At least ``caller_file`` or ``suite`` must be used, otherwise a
``TypeError`` will be raised.
"""
if not args:
if not parser:
parser = self.parse_args()
Annotation
- Detected declarations: `function print`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.