Answer the question
In order to leave comments, you need to log in
Python how to properly test a class with the unittest module?
Hello !
Decided to get to testing in python.
There is such a script.
"""Пример"""
import unittest
class Hello:
def __init__(self):
self.value = ""
def name(self, value):
self.value = value
def show(self):
if self.name == "":
return "Hello user!"
else:
return str("Hello " + self.value + "!")
if __name__ == '__main__':
hello = Hello()
hello.name("Александр")
print(hello.show())
Answer the question
In order to leave comments, you need to log in
If the code consists of shit and sticks, then three tests are needed - for shit, for sticks and integration.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question