speccpu/x264: doctest for speccpu.x264.MCBuilder.get_src
This commit is contained in:
@@ -12,6 +12,28 @@ def get_mc_path(build):
|
|||||||
class MCBuilder:
|
class MCBuilder:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_src():
|
def get_src():
|
||||||
|
"""
|
||||||
|
Get the source code of the motion compensation (mc.c) file.
|
||||||
|
|
||||||
|
This static method reads and returns the content of the mc.c file,
|
||||||
|
which is part of the x264 benchmark package. The file is accessed
|
||||||
|
using importlib.resources to ensure proper resource handling.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: The complete source code of the mc.c file as a string.
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
AssertionError: If the function is called from a module that is not part of a package.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
>>> src = MCBuilder.get_src()
|
||||||
|
>>> isinstance(src, str)
|
||||||
|
True
|
||||||
|
>>> "mc_weight" in src
|
||||||
|
True
|
||||||
|
>>> len(src) > 0
|
||||||
|
True
|
||||||
|
"""
|
||||||
assert __package__ is not None
|
assert __package__ is not None
|
||||||
with (importlib.resources.files(__package__) / "mc.c").open("r") as f:
|
with (importlib.resources.files(__package__) / "mc.c").open("r") as f:
|
||||||
mc_src = f.read()
|
mc_src = f.read()
|
||||||
|
|||||||
Reference in New Issue
Block a user