You are viewing a single comment's thread. Return to all comments →
Pythonista! This is very good case to demonstrate your OOP skills. Make your test class valuable for real business case:
randmo.seed()
from random import seed, sample, randint seed(250) class TestDataEmptyArray: static_array: list[int] = [] @classmethod def get_array(cls) -> list[int]: return cls.static_array class TestDataUniqueValues(TestDataEmptyArray): static_min_val = randint(0,1000) static_array_ordered: list[int] = [i for i in range(static_min_val, static_min_val*100)] static_array: list[int] = sample(static_array_ordered, len(static_array_ordered)) @classmethod def get_expected_result(cls) -> int: return cls.static_array.index(cls.static_min_val) class TestDataExactlyTwoDifferentMinimums(TestDataUniqueValues): static_min_val= randint(0,1000) static_array_ordered: list[int] = [i for i in range(static_min_val, static_min_val*100)] + [static_min_val] static_array: list[int] = sample(static_array_ordered, len(static_array_ordered))
Happy pythoning!
🦁
Seems like cookies are disabled on this browser, please enable them to open this website
Day 27: Testing
You are viewing a single comment's thread. Return to all comments →
Python 3
Pythonista! This is very good case to demonstrate your OOP skills. Make your test class valuable for real business case:
randmo.seed()
)Happy pythoning!
🦁