mirror of
https://github.com/Hizenberg469/Python-tutorial.git
synced 2026-04-19 23:12:24 +03:00
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
import unittest
|
|
import random
|
|
|
|
globals = None
|
|
report = unittest.Report()
|
|
class ODD_EVEN_TEST_001(unittest.SystemTestCase):
|
|
|
|
@classmethod
|
|
def setUpClass(inst):
|
|
""" Add the initial configuration if any """
|
|
|
|
@classmethod
|
|
def tearDownClass(inst):
|
|
""" Add the teardown configuration if any """
|
|
|
|
# """Add the definitions for tests defined in suite here"""
|
|
# def dummy_assert(self):
|
|
# report.normal("This is normal print")
|
|
# report.error("This is errored print")
|
|
# report.notification("This is notify print")
|
|
# assrt=unittest.Assert(self)
|
|
# assrt.isEquals("1", "2", "1 Equals 2")
|
|
# assrt.isEquals("1", "1", "1 Equals 2")
|
|
|
|
def generate_number(self,seed_value):
|
|
random.seed(seed_value)
|
|
|
|
gen_value = random.randrange(1,7)
|
|
|
|
return gen_value
|
|
|
|
|
|
def check_testcase(self):
|
|
|
|
for x in range(1,26):
|
|
generated_value = self.generate_number(x)
|
|
|
|
report.normal(f'For test case {x}:')
|
|
assrt = unittest.Assert(self)
|
|
|
|
if( generated_value == 3):
|
|
assrt.isEquals("1",str(generated_value), "You win!!!")
|
|
elif( generated_value == 6):
|
|
assrt.isEquals("6",str(generated_value), "You win!!!")
|
|
else:
|
|
assrt.isEquals("6",str(generated_value), "You lose!!!")
|
|
|
|
|
|
def suite():
|
|
suite = unittest.TestSuite()
|
|
"""Add your tests into the suite here"""
|
|
suite.addTest(ODD_EVEN_TEST_001("check_testcase"))
|
|
return suite
|
|
|
|
def main():
|
|
runner = unittest.TextTestRunner()
|
|
return runner.run(suite())
|