diff options
-rw-r--r-- | rtemsspec/content.py | 4 | ||||
-rw-r--r-- | rtemsspec/tests/test_content.py | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/rtemsspec/content.py b/rtemsspec/content.py index 5bccd325..9651664e 100644 --- a/rtemsspec/content.py +++ b/rtemsspec/content.py @@ -1208,8 +1208,10 @@ def get_integer_type(value: int) -> str: return f"uint{power}_t" -def duration(value: float) -> str: +def duration(value: Union[float, str]) -> str: """ Converts a duration in seconds into a value with unit string. """ + if isinstance(value, str): + return value assert value >= 0.0 if value == 0.0: return "0s" diff --git a/rtemsspec/tests/test_content.py b/rtemsspec/tests/test_content.py index e2a17d12..6bc344fa 100644 --- a/rtemsspec/tests/test_content.py +++ b/rtemsspec/tests/test_content.py @@ -333,6 +333,7 @@ def test_enabled_by_to_python_exp(): def test_duration(): + assert duration("abc") == "abc" assert duration(1.0) == "1.000s" assert duration(0.0) == "0s" assert duration(0.001) == "1.000ms" |