Пример #1
0
class TestMammal(TestCase):
    name = "Name"
    mammal_type = "Type"
    sound = "Sound"
    kingdom = "animals"

    def setUp(self) -> None:
        self.mammal = Mammal(self.name, self.mammal_type, self.sound)

    def test_mammal_initialization(self):
        self.assertEqual(self.name, self.mammal.name)
        self.assertEqual(self.mammal_type, self.mammal.type)
        self.assertEqual(self.sound, self.mammal.sound)
        self.assertEqual("animals", self.mammal._Mammal__kingdom)

    def test_make_sound_should_return_sound_as_a_string(self):
        expected = f"{self.mammal.name} makes {self.mammal.sound}"
        actual = self.mammal.make_sound()
        self.assertEqual(expected, actual)

    def test_get_kingdom__should_return_kingdom_as_string(self):
        expected = "animals"
        actual = self.mammal.get_kingdom()
        self.assertEqual(expected, actual)

    def test_info__should_return_info_about_name_and_type(self):
        expected = f"{self.mammal.name} is of type {self.mammal.type}"
        actual = self.mammal.info()
        self.assertEqual(expected, actual)
Пример #2
0
class MammalTest(unittest.TestCase):
    name = "Harambe"
    type = "gorilla"
    sound = "roar"

    def setUp(self) -> None:
        self.mammal = Mammal(self.name, self.type, self.sound)

    def test_mammal_private_attribute_kingdom(self):
        self.assertEqual("animals", self.mammal._Mammal__kingdom)

    def test_mammal_make_sound(self):
        expected = f"{self.name} makes {self.sound}"
        actual = self.mammal.make_sound()
        self.assertEqual(expected, actual)

    def test_mammal_get_kigdom(self):
        expected = "animals"
        actual = self.mammal.get_kingdom()
        self.assertEqual(expected, actual)

    def test_mammal_info(self):
        expected = f"{self.name} is of type {self.type}"
        actual = self.mammal.info()
        self.assertEqual(expected, actual)
Пример #3
0
class TestMammal(TestCase):
    name = 'Mammal name'
    type = 'mammal type'
    sound = 'mammal sound'

    def setUp(self) -> None:
        self.mammal = Mammal(self.name, self.type, self.sound)

    def test_check_instance_attr_are_set(self):
        self.assertEqual('Mammal name', self.mammal.name)
        self.assertEqual('mammal type', self.mammal.type)
        self.assertEqual('mammal sound', self.mammal.sound)

    def test_make_sound__expect_correct_sound(self):
        self.assertEqual('Mammal name makes mammal sound', self.mammal.make_sound())

    def test_kingdom_initial(self):
        result = self.mammal._Mammal__kingdom
        expected_result = 'animals'
        self.assertEqual(result, expected_result)

    def test_get_kingdom__expected_correct_kingdom(self):
        self.assertEqual('animals', self.mammal.get_kingdom())


    def test_get_info__expect_correct_value(self):
        expected_info = 'Mammal name is of type mammal type'
        actual_info = self.mammal.info()
        self.assertEqual(expected_info, actual_info)
Пример #4
0
class MammalTest(TestCase):
    name = 'Kitty'
    mammal_type = 'cat'
    sound = 'meow'
    kingdom = 'animals'

    def setUp(self) -> None:
        self.mammal = Mammal(self.name, self.mammal_type, self.sound)

    def test_attrs_set_correctly(self):
        self.assertEqual('Kitty', self.mammal.name)
        self.assertEqual('cat', self.mammal.type)
        self.assertEqual('meow', self.mammal.sound)
        self.assertEqual(self.kingdom, self.mammal._Mammal__kingdom)

    def test_make_sound(self):
        self.assertEqual(f"{self.mammal.name} makes {self.mammal.sound}",
                         self.mammal.make_sound())

    def test_get_kingdom(self):
        self.assertEqual("animals", self.mammal.get_kingdom())

    def test_get_info(self):
        self.assertEqual(f"{self.mammal.name} is of type {self.mammal.type}",
                         self.mammal.info())
Пример #5
0
 def test_initialized_when_with_correct_name_type_sound(self):
     mammal = Mammal('Suzi', 'dog', 'bow bow')
     self.assertEqual('Suzi', mammal.name)
     self.assertEqual('dog', mammal.type)
     self.assertEqual('bow bow', mammal.sound)
     actual_kingdom = mammal.get_kingdom()
     self.assertEqual('animals', actual_kingdom )
Пример #6
0
class TestMammal(unittest.TestCase):
    def setUp(self) -> None:
        self.test_mammal = Mammal('test_name', 'cat', 'bow bow')

    def test_initialized_when_with_correct_name_type_sound(self):
        mammal = Mammal('Suzi', 'dog', 'bow bow')
        self.assertEqual('Suzi', mammal.name)
        self.assertEqual('dog', mammal.type)
        self.assertEqual('bow bow', mammal.sound)
        actual_kingdom = mammal.get_kingdom()
        self.assertEqual('animals', actual_kingdom )


    def test_make_sound_should_return_message(self):
        actual = self.test_mammal.make_sound()
        expected = "test_name makes bow bow"
        self.assertEqual(actual, expected)

    def test_get_kingdom(self):
        actual = self.test_mammal.get_kingdom()
        expected = "animals"
        self.assertEqual(actual, expected)

    def test_info(self):
        actual = self.test_mammal.info()
        expected = "test_name is of type cat"
        self.assertEqual(actual, expected)
Пример #7
0
class MammalTest(unittest.TestCase):
    def setUp(self):
        self.mammal = Mammal('Pol', 'cat', 'mql')

    def test_name(self):
        self.assertEqual('Pol', self.mammal.name)

    def test_type(self):
        type_animal = self.mammal.type
        self.assertEqual('cat', type_animal)

    def test_sound(self):
        type_sound = self.mammal.sound
        self.assertEqual('mql', type_sound)

    def test_get_make_sound(self):
        sound = self.mammal.make_sound()
        self.assertEqual(sound, 'Pol makes mql')

    def test_kingdom_initial(self):
        result = self.mammal._Mammal__kingdom
        expected_result = "animals"
        self.assertEqual(result, expected_result)

    def test_get_kingdom(self):
        info = self.mammal.get_kingdom()
        self.assertEqual(info, 'animals')

    def test_info(self):
        info = self.mammal.info()
        self.assertEqual(info, 'Pol is of type cat')
Пример #8
0
 def test(self):
     mammal = Mammal("Stella")
     self.assertEqual(mammal.__class__.__bases__[0].__name__, "Animal")
     self.assertEqual(mammal.name, "Stella")
     lizard = Lizard("John")
     self.assertEqual(lizard.__class__.__bases__[0].__name__, "Reptile")
     self.assertEqual(lizard .name, "John")
Пример #9
0
class TestMammal(TestCase):
    def setUp(self):
        self.animal = Mammal('Tom', 'cat', 'meow')

    def test_initialization(self):
        self.assertEqual('Tom', self.animal.name)
        self.assertEqual('cat', self.animal.type)
        self.assertEqual('meow', self.animal.sound)
        self.assertEqual('animals', self.animal._Mammal__kingdom)

    def test_making_sound(self):
        self.assertEqual("Tom makes meow", self.animal.make_sound())

    def test_get_kingdom(self):
        self.assertEqual('animals', self.animal.get_kingdom())

    def test_get_info(self):
        self.assertEqual('Tom is of type cat', self.animal.info())
Пример #10
0
class TestMammal(TestCase):
    def setUp(self):
        self.mammal = Mammal("Test", "Bear", "roar")

    def test_initialization_all_attributes(self):
        self.assertEqual("Test", self.mammal.name)
        self.assertEqual("Bear", self.mammal.type)
        self.assertEqual("roar", self.mammal.sound)
        self.assertEqual("animals", self.mammal._Mammal__kingdom)

    def test_mammal_make_sound(self):
        self.assertEqual(f"Test makes roar", self.mammal.make_sound())

    def test_get_kingdom_getter(self):
        self.assertEqual("animals", self.mammal.get_kingdom())

    def test_get_mammal_info(self):
        self.assertEqual(f"Test is of type Bear", self.mammal.info())
Пример #11
0
class TestMammal(unittest.TestCase):
    def setUp(self):
        self.animal = Mammal('name', 'cat', 'meow')

    def test_all_set_up(self):
        self.assertEqual(self.animal.name, 'name')
        self.assertEqual(self.animal.type, 'cat')
        self.assertEqual(self.animal.sound, 'meow')
        self.assertEqual(self.animal._Mammal__kingdom, 'animals')

    def test_make_sound(self):
        self.assertEqual(self.animal.make_sound(), f"name makes meow")

    def test_get_kingdom(self):
        self.assertEqual(self.animal.get_kingdom(), 'animals')

    def test_info_message(self):
        self.assertEqual(self.animal.info(), 'name is of type cat')
Пример #12
0
class TestMammal(TestCase):
    def setUp(self):  # name, mammal_type, sound
        self.mammal = Mammal("Amy", "Lion", "Roar")

    def test_init(self):
        self.assertEqual("Amy", self.mammal.name)
        self.assertEqual("Lion", self.mammal.type)
        self.assertEqual("Roar", self.mammal.sound)
        self.assertEqual("animals", self.mammal._Mammal__kingdom)

    def test_making_sound(self):
        self.assertEqual(f"Amy makes Roar", self.mammal.make_sound())

    def test_get_kingdom(self):
        self.assertEqual("animals", self.mammal.get_kingdom())

    def test_get_info(self):
        self.assertEqual(f"Amy is of type Lion", self.mammal.info())
class TestMammal(unittest.TestCase):
    def setUp(self):
        self.mammal = Mammal('kuche', 'cat', 'mooou')

    def test_mammal_init_method_initialize_correct(self):
        self.assertEqual(self.mammal.name, 'kuche')
        self.assertEqual(self.mammal.type, 'cat')
        self.assertEqual(self.mammal.sound, 'mooou')
        self.assertEqual(self.mammal._Mammal__kingdom, 'animals')

    def test_mammal_method_make_sound_should_return_correct_string(self):
        self.assertEqual(self.mammal.make_sound(), 'kuche makes mooou')

    def test_mammal_get_kingdom_method(self):
        self.assertEqual(self.mammal.get_kingdom(), 'animals')

    def test_mammal_info(self):
        self.assertEqual(self.mammal.info(), 'kuche is of type cat')
Пример #14
0
class TestMammal(TestCase):
    def setUp(self):
        self.mammal = Mammal("Manol", "Manolov", "Bitcoin")

    def test_init_atr(self):
        self.assertEqual("Manol", self.mammal.name)
        self.assertEqual("Manolov", self.mammal.type)
        self.assertEqual("Bitcoin", self.mammal.sound)
        self.assertEqual("animals", self.mammal.get_kingdom())

    def test_make_sound(self):
        result = self.mammal.make_sound()
        self.assertEqual("Manol makes Bitcoin", result)

    def test_get_kingdom(self):
        result = self.mammal.get_kingdom()
        self.assertEqual("animals", result)

    def test_info(self):
        self.assertEqual("Manol is of type Manolov", self.mammal.info())
Пример #15
0
class MammalTest(unittest.TestCase):
    def setUp(self) -> None:
        self.mammal = Mammal("Bobby", "dog", "bau")

    def test_constructor(self):
        self.assertEqual("Bobby", self.mammal.name)
        self.assertEqual("dog", self.mammal.type)
        self.assertEqual("bau", self.mammal.sound)
        self.assertEqual("animals", self.mammal._Mammal__kingdom)

    def test_make_sound(self):
        expect = "Bobby makes bau"
        self.assertEqual(expect, self.mammal.make_sound())

    def test_get_kingdom(self):
        self.assertEqual("animals", self.mammal.get_kingdom())

    def test_repr(self):
        expect = "Bobby is of type dog"
        self.assertEqual(expect, self.mammal.info())
Пример #16
0
class TestMammal(unittest.TestCase):
    def setUp(self):
        self.animal = Mammal("Tiger", "cats", "GRR")

    def test_init(self):
        self.assertEqual(self.animal.name, "Tiger")
        self.assertEqual(self.animal.type, "cats")
        self.assertEqual(self.animal.sound, "GRR")

    def test_private_attribute(self):
        self.assertEqual(self.animal._Mammal__kingdom, "animals")

    def test_make_sound(self):
        self.assertEqual(self.animal.make_sound(), "Tiger makes GRR")

    def test_get_kingdom(self):
        self.assertEqual(self.animal.get_kingdom(), "animals")

    def test_info(self):
        self.assertEqual(self.animal.info(), "Tiger is of type cats")
Пример #17
0
class MammalTests(unittest.TestCase):
    def setUp(self) -> None:
        self.mammal = Mammal(ANIMAL_NAME, ANIMAL_TYPE, ANIMAL_SOUND)

    def test_animal_init(self):
        self.assertEqual(ANIMAL_NAME, self.mammal.name)
        self.assertEqual(ANIMAL_TYPE, self.mammal.type)
        self.assertEqual(ANIMAL_SOUND, self.mammal.sound)
        self.assertEqual('animals', self.mammal._Mammal__kingdom)

    def test_animal_can_make_sound(self):
        expected = 'Test makes bark'
        self.assertEqual(expected, self.mammal.make_sound())

    def test_animal_can_report_info(self):
        expected = 'Test is of type dog'
        self.assertEqual(expected, self.mammal.info())

    def test_animal_can_report_kingdom(self):

        self.assertEqual(KINGDOM, self.mammal.get_kingdom())
Пример #18
0
class TestMammal(unittest.TestCase):
    def setUp(self):
        self.mammal = Mammal('a', 'b', 'c')

    def test_constructor(self):
        self.assertEqual(self.mammal.name, 'a')
        self.assertEqual(self.mammal.type, 'b')
        self.assertEqual(self.mammal.sound, 'c')
        self.assertEqual(self.mammal.get_kingdom(), 'animals')

    def test_get_kingdom(self):
        kingdom = self.mammal.get_kingdom()
        self.assertEqual('animals', kingdom)

    def test_make_sound(self):
        expected = f"{self.mammal.name} makes {self.mammal.sound}"
        self.assertEqual(self.mammal.make_sound(), expected)

    def test_info(self):
        expected = f"{self.mammal.name} is of type {self.mammal.type}"
        self.assertEqual(self.mammal.info(), expected)
Пример #19
0
class TestMammal(TestCase):
    name = 'Molly'
    type = 'Dog'
    sound = 'woof woof'

    def setUp(self):
        self.my_dog = Mammal(self.name, self.type, self.sound)

    def test_make_sound(self):
        self.assertEqual(f'Molly makes woof woof', self.my_dog.make_sound())

    def test_get_kingdom(self):
        self.assertEqual('animals', self.my_dog.get_kingdom())

    def test_info(self):
        self.assertEqual("Molly is of type Dog", self.my_dog.info())

    def test_init(self):
        self.assertEqual(self.name, self.my_dog.name)
        self.assertEqual(self.type, self.my_dog.type)
        self.assertEqual(self.sound, self.my_dog.sound)
Пример #20
0
class TestMammal(unittest.TestCase):
    def setUp(self):
        self.mammal = Mammal('Aron', 'Dog', 'Bark')

    def test_mammal__attributes_are_set(self):
        self.assertEqual("Aron", self.mammal.name)
        self.assertEqual('Dog', self.mammal.type)
        self.assertEqual('Bark', self.mammal.sound)

    def test_mammal__make_sound(self):
        result = self.mammal.make_sound()
        expected_result = 'Aron makes Bark'
        self.assertEqual(expected_result, result)

    def test_mammal__get_kingdom(self):
        result = self.mammal.get_kingdom()
        expected_result = 'animals'
        self.assertEqual(expected_result, result)

    def test_mammal__get_info(self):
        result = self.mammal.info()
        expected_result = f'Aron is of type Dog'
        self.assertEqual(expected_result, result)
Пример #21
0
class MammalTests(unittest.TestCase):
    name = "Jordan"
    mammal_type = "Bear"
    sound = "Roar"

    def setUp(self):
        self.m = Mammal(self.name, self.mammal_type, self.sound)

    def test_correct_initiolization_mammal(self):
        self.assertEqual(self.name, self.m.name)
        self.assertEqual(self.mammal_type, self.m.type)
        self.assertEqual(self.sound, self.m.sound)
        self.assertEqual("animals", self.m._Mammal__kingdom)

    def test_make_sound_correct_returt_string(self):
        self.assertEqual(f"{self.name} makes {self.sound}",
                         self.m.make_sound())

    def test_get_kingdom_correct_return_privite_property__kingdom(self):
        self.assertEqual("animals", self.m.get_kingdom())

    def test_info_correct_return_of_string_info(self):
        self.assertEqual(f"{self.name} is of type {self.mammal_type}",
                         self.m.info())
Пример #22
0
 def __init__(self, name):
     Mammal.__init__(self, name)
Пример #23
0
from project.lizard import Lizard
from project.mammal import Mammal

mammal = Mammal("Stella")
print(mammal.__class__.__bases__[0].__name__)
print(mammal.name)
print(mammal._Animal__name)
lizard = Lizard("John")
print(lizard.__class__.__bases__[0].__name__)
print(lizard.name)
print(lizard._Animal__name)
Пример #24
0
 def setUp(self) -> None:
     self.mammal = Mammal(self.name, self.mammal_type, self.sound)
Пример #25
0
 def setUp(self):
     self.my_dog = Mammal(self.name, self.type, self.sound)
Пример #26
0
 def setUp(self):
     self.animal = Mammal('name', 'cat', 'meow')
Пример #27
0
 def setUp(self):
     self.mammal = Mammal("Manol", "Manolov", "Bitcoin")
Пример #28
0
 def setUp(self):
     self.animal = Mammal('Tom', 'cat', 'meow')
Пример #29
0
 def setUp(self):
     self.mammal = Mammal('Aron', 'Dog', 'Bark')
Пример #30
0
 def setUp(self):
     self.animal = Mammal("Tiger", "cats", "GRR")