Merge pull request #11 from Kamoppl/kamilg/generate_random_size

test-framework: add generate random size method
This commit is contained in:
Daniel Madej 2024-09-05 07:43:34 +02:00 committed by GitHub
commit 6b3c653e94
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,10 +1,12 @@
# #
# Copyright(c) 2019-2021 Intel Corporation # Copyright(c) 2019-2021 Intel Corporation
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
import enum import enum
import math import math
import random
from multimethod import multimethod from multimethod import multimethod
@ -209,3 +211,8 @@ class Size:
@staticmethod @staticmethod
def zero(): def zero():
return Size(0) return Size(0)
@staticmethod
def generate_random_size(min_size: int, max_size: int, unit: Unit):
size = random.randint(min_size, max_size)
return Size(value=float(size), unit=unit)