code: def test_checkout(self):
      # Setup and create all environment files
      self.__setup()
  
      # Create environment to checkout to with defaults
      environment_obj = self.environment_controller.create({})
      self.environment_ids.append(environment_obj.id)
      # Checkout success with there are no unstaged changes
      result = self.environment_controller.checkout(environment_obj.id)
      assert result
      current_hash = (
          self.environment_controller._calculate_project_environment_hash()
      )
      assert environment_obj.unique_hash == current_hash
      # Check the filenames as well because the hash does not take this into account
      assert os.path.isfile(
          os.path.join(
              self.environment_controller.environment_driver.environment_directory_path,
              "test",
          )
      )
      assert os.path.isfile(
          os.path.join(
              self.environment_controller.environment_driver.environment_directory_path,
              "Dockerfile",
          )
      )
      assert not os.path.isfile(
          os.path.join(
              self.environment_controller.environment_driver.environment_directory_path,
              "datmoDockerfile",
          )
      )
      assert not os.path.isfile(
          os.path.join(
              self.environment_controller.environment_driver.environment_directory_path,
              "hardware_info",
          )
      )
  
      # Change file contents to make it unstaged
      with open(self.definition_filepath, "wb") as f:
          f.write(to_bytes("new content"))
  
      # Checkout failure with unstaged changes
      failed = False
      try:
          _ = self.environment_controller.checkout(environment_obj.id)
      except UnstagedChanges:
          failed = True
      assert failed
  
      # Create new environment to checkout to with defaults (no hardware)
      environment_obj_1 = self.environment_controller.create(
          {}, save_hardware_file=False
      )
      self.environment_ids.append(environment_obj_1.id)
      # Checkout success with there are no unstaged changes
      result = self.environment_controller.checkout(environment_obj.id)
      assert result
      current_hash = (
          self.environment_controller._calculate_project_environment_hash()
      )
      assert environment_obj.unique_hash == current_hash
      assert environment_obj_1.unique_hash != current_hash
      # Check the filenames as well because the hash does not take this into account
      assert os.path.isfile(
          os.path.join(
              self.environment_controller.environment_driver.environment_directory_path,
              "test",
          )
      )
      assert os.path.isfile(
          os.path.join(
              self.environment_controller.environment_driver.environment_directory_path,
              "Dockerfile",
          )
      )
      assert not os.path.isfile(
          os.path.join(
              self.environment_controller.environment_driver.environment_directory_path,
              "datmoDockerfile",
          )
      )
      assert not os.path.isfile(
          os.path.join(
              self.environment_controller.environment_driver.environment_directory_path,
              "hardware_info",
          )
      )
  
imports: import os
  import uuid
  import threading
  import tempfile
  import platform
  import timeout_decorator
  from io import open
  from datmo.config import Config
  from datmo.core.controller.project import ProjectController
  from datmo.core.controller.environment.environment import EnvironmentController
  from datmo.core.entity.environment import Environment
  from datmo.core.util.exceptions import EntityNotFound, RequiredArgumentMissing, TooManyArgumentsFound, FileAlreadyExistsError, UnstagedChanges, EnvironmentDoesNotExist, ProjectNotInitialized
  from datmo.core.util.misc_functions import check_docker_inactive, pytest_docker_environment_failed_instantiation
label_desc: Use image node_id 24 for calling the TestEnvironmentController obj's underlying member method code with example usage: obj.test_checkout() without return types