code: def with_context(cls, setup_phases, teardown_phases):
      
      setup = flatten_phases_and_groups(setup_phases)
      teardown = flatten_phases_and_groups(teardown_phases)
  
      def _context_wrapper(*phases):
        return cls(setup=setup,
                   main=flatten_phases_and_groups(phases),
                   teardown=teardown)
      return _context_wrapper
docs: Create PhaseGroup creator function with setup and teardown phases.
  
      Args:
        setup_phases: list of phase_descriptor.PhaseDescriptors/PhaseGroups/
            callables/iterables, phases to run during the setup for the PhaseGroup
            returned from the created function.
        teardown_phases: list of phase_descriptor.PhaseDescriptors/PhaseGroups/
            callables/iterables, phases to run during the teardown for the
            PhaseGroup returned from the created function.
  
      Returns:
        Function that takes *phases and returns a PhaseGroup with the predefined
        setup and teardown phases, with *phases as the main phases.