Doggie Day Care Given the TestDog class below, write a Dog class that will pass the tests contained in our test class. Do NOT change anything in our test class! Your Dog class must provide the following methods to adequately pass our tests: * __init__ (takes a string name of dog, int age and Boolean indicating a purebred or not), * is_purebred (returns True or False depending on if the dog is a purebred) * clone (makes a non-mutated copy of the current object) * __str__ returns a string representation of the object * __eq__ returns True or False when comparing two instances of the Dog class import unittest from coding import Dog class TestDog(unittest.TestCase): ''' class to test all the methods of the Dog class         imports from TestCase Compares inputs and expected outputs with all SimpleFraction methods: * __init__, * is_purebred, * clone (makes a non-mutated copy of the current object) * __str__, represent the Dog as a string * __eq__, compare current object with another Dog. Are they equal? '''               def test_init(self):       d = Dog("Fido", 10, True) self.assertEqual(d.name, "Fido") self.assertEqual(d.age, 10) self.assertTrue(d.is_purebred()) d2 = Dog("Fifi", 11, False) self.assertEqual(d2.name, "Fifi") self.assertEqual(d2.age, 11) self.assertFalse(d2.is_purebred())   def test_bad_init(self):      with self.assertRaises(ValueError):          d = Dog("Fido", -10, True) def test_is_purebred(self):        d = Dog("Fido", 10, True)        d2 = Dog("Fifi", 11, False)  self.assertTrue(d.is_purebred())  self.assertFalse(d2.is_purebred()) def test_eq(self):        d = Dog("Fido", 10, True)        d2 = Dog("Fifi", 11, False)         d3 = Dog("Fifi", 11, False)         self.assertTrue(d2.__eq__(d3))         self.assertFalse(d.__eq__(d2))         self.assertTrue(d2 == d3)        self.assertFalse(d == d2)   def test_clone(self): d2 = Dog("Fifi", 11, False) d3 = d2.clone() self.assertIsNot(d2,d3) # should NOT be same object! self.assertEqual(d2, d3) # but SHOULD be equal! def test_str(self): d = Dog("Fido", 10, True) d2 = Dog("Fifi", 11, False) msg = "Purebred: Fido 10 years" self.assertEqual(d.__str__(), msg) msg = "NOT Purebred: Fifi 11 years" self.assertEqual(d2.__str__(), msg) def main():        unittest.main(verbosity = 3) main()

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Doggie Day Care
Given the TestDog class below, write a Dog class that will pass the tests contained in our test class. Do NOT change anything in our test class!

Your Dog class must provide the following methods to adequately pass our tests:
* __init__ (takes a string name of dog, int age and Boolean indicating a purebred or

not),
* is_purebred (returns True or False depending on if the dog is a purebred) * clone (makes a non-mutated copy of the current object)
* __str__ returns a string representation of the object
* __eq__ returns True or False when comparing two instances of the Dog class

import unittest

from coding import Dog

class TestDog(unittest.TestCase):
''' class to test all the methods of the Dog class

        imports from TestCase

Compares inputs and expected outputs with all SimpleFraction methods: * __init__,
* is_purebred,
* clone (makes a non-mutated copy of the current object)

* __str__, represent the Dog as a string

* __eq__, compare current object with another Dog. Are they equal? '''

 

 

 

 

 

 

 

def test_init(self):
      d = Dog("Fido", 10, True)

self.assertEqual(d.name, "Fido")

self.assertEqual(d.age, 10)

self.assertTrue(d.is_purebred())

d2 = Dog("Fifi", 11, False)

self.assertEqual(d2.name, "Fifi")

self.assertEqual(d2.age, 11)

self.assertFalse(d2.is_purebred())

 

def test_bad_init(self):
     with self.assertRaises(ValueError):

         d = Dog("Fido", -10, True)

def test_is_purebred(self):
       d = Dog("Fido", 10, True)
       d2 = Dog("Fifi", 11, False)

 self.assertTrue(d.is_purebred())

 self.assertFalse(d2.is_purebred())

def test_eq(self):       

d = Dog("Fido", 10, True)       

d2 = Dog("Fifi", 11, False)      

  d3 = Dog("Fifi", 11, False)

        self.assertTrue(d2.__eq__(d3))

        self.assertFalse(d.__eq__(d2))

        self.assertTrue(d2 == d3)        self.assertFalse(d == d2)

 

def test_clone(self):


d2 = Dog("Fifi", 11, False)
d3 = d2.clone()
self.assertIsNot(d2,d3) # should NOT be same object! self.assertEqual(d2, d3) # but SHOULD be equal!

def test_str(self):


d = Dog("Fido", 10, True)
d2 = Dog("Fifi", 11, False)
msg = "Purebred: Fido 10 years"

self.assertEqual(d.__str__(), msg)

msg = "NOT Purebred: Fifi 11 years"

self.assertEqual(d2.__str__(), msg)

def main():

       unittest.main(verbosity = 3)

main()

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY