import unittest
from src.dojo import Dojo


class TestCreateRoom (unittest.TestCase):

    def setUp(self):
        self.dojo = Dojo()
        self.test_office = self.dojo.create_room("office", "test")
        self.test_living_space = self.dojo.create_room("living_space", "test living space")

    def test_create_room_successfully(self):
        initial_room_count = len(self.dojo.all_rooms)
        blue_office = self.dojo.create_room("office", "Blue")
        self.assertTrue(blue_office)
        new_room_count = len(self.dojo.all_rooms)
        self.assertEqual(new_room_count - initial_room_count, 1)

    def test_create_rooms_successfully(self):
        my_class_instance = Dojo()
        initial_room_count = len(my_class_instance.all_rooms)
        offices = my_class_instance.create_room("office", "Blue", "Black", "Brown")
        self.assertTrue(offices)
        new_room_count = len(my_class_instance.all_rooms)
        self.assertEqual(new_room_count - initial_room_count, 3)
import unittest
from src.dojo import Dojo


class TestCreateRoom (unittest.TestCase):

    def setUp(self):
        self.dojo = Dojo()
        self.test_office = self.dojo.create_room("office", "test")
        self.test_living_space = self.dojo.create_room("living_space", "test living space")

    def test_create_room_successfully(self):
        initial_room_count = len(self.dojo.all_rooms)
        blue_office = self.dojo.create_room("office", "Blue")
        self.assertTrue(blue_office)
        new_room_count = len(self.dojo.all_rooms)
        self.assertEqual(new_room_count - initial_room_count, 1)

    def test_create_rooms_successfully(self):
        initial_room_count = len(self.dojo.all_rooms)
        offices = self.dojo.create_room("office", "Blue", "Black", "Brown")
        self.assertTrue(offices)
        new_room_count = len(self.dojo.all_rooms)
        self.assertEqual(new_room_count - initial_room_count, 3)
Change test for multiple rooms to use test set-up
Change test for multiple rooms to use test set-up

  import unittest
  from src.dojo import Dojo
  
  
  class TestCreateRoom (unittest.TestCase):
  
      def setUp(self):
          self.dojo = Dojo()
          self.test_office = self.dojo.create_room("office", "test")
          self.test_living_space = self.dojo.create_room("living_space", "test living space")
  
      def test_create_room_successfully(self):
          initial_room_count = len(self.dojo.all_rooms)
          blue_office = self.dojo.create_room("office", "Blue")
          self.assertTrue(blue_office)
          new_room_count = len(self.dojo.all_rooms)
          self.assertEqual(new_room_count - initial_room_count, 1)
  
      def test_create_rooms_successfully(self):
-         my_class_instance = Dojo()
-         initial_room_count = len(my_class_instance.all_rooms)
+         initial_room_count = len(self.dojo.all_rooms)
-         offices = my_class_instance.create_room("office", "Blue", "Black", "Brown")
+         offices = self.dojo.create_room("office", "Blue", "Black", "Brown")
          self.assertTrue(offices)
-         new_room_count = len(my_class_instance.all_rooms)
+         new_room_count = len(self.dojo.all_rooms)
          self.assertEqual(new_room_count - initial_room_count, 3)
Change test for multiple rooms to use test set-up
## Code Before:
import unittest
from src.dojo import Dojo


class TestCreateRoom (unittest.TestCase):

    def setUp(self):
        self.dojo = Dojo()
        self.test_office = self.dojo.create_room("office", "test")
        self.test_living_space = self.dojo.create_room("living_space", "test living space")

    def test_create_room_successfully(self):
        initial_room_count = len(self.dojo.all_rooms)
        blue_office = self.dojo.create_room("office", "Blue")
        self.assertTrue(blue_office)
        new_room_count = len(self.dojo.all_rooms)
        self.assertEqual(new_room_count - initial_room_count, 1)

    def test_create_rooms_successfully(self):
        my_class_instance = Dojo()
        initial_room_count = len(my_class_instance.all_rooms)
        offices = my_class_instance.create_room("office", "Blue", "Black", "Brown")
        self.assertTrue(offices)
        new_room_count = len(my_class_instance.all_rooms)
        self.assertEqual(new_room_count - initial_room_count, 3)
## Instruction:
Change test for multiple rooms to use test set-up
## Code After:
import unittest
from src.dojo import Dojo


class TestCreateRoom (unittest.TestCase):

    def setUp(self):
        self.dojo = Dojo()
        self.test_office = self.dojo.create_room("office", "test")
        self.test_living_space = self.dojo.create_room("living_space", "test living space")

    def test_create_room_successfully(self):
        initial_room_count = len(self.dojo.all_rooms)
        blue_office = self.dojo.create_room("office", "Blue")
        self.assertTrue(blue_office)
        new_room_count = len(self.dojo.all_rooms)
        self.assertEqual(new_room_count - initial_room_count, 1)

    def test_create_rooms_successfully(self):
        initial_room_count = len(self.dojo.all_rooms)
        offices = self.dojo.create_room("office", "Blue", "Black", "Brown")
        self.assertTrue(offices)
        new_room_count = len(self.dojo.all_rooms)
        self.assertEqual(new_room_count - initial_room_count, 3)