class_docstr: Context manager to mock a system command.
  
  The mock command will be written to a directory at the front of $PATH,
  taking precedence over any existing command with the same name.
  
  The *python* parameter accepts a string of code for the command to run,
  in addition to the default behaviour of recording calls to the command.
  This will run with the same Python interpreter as the calling code, but in
  a new process.
  
  The *content* parameter gives extra control, by providing a script which
  will run with no additions. On Unix, it should start with a shebang (e.g.
  ``#!/usr/bin/env python``) specifying the interpreter. On Windows, it will
  always be run by the same Python interpreter as the calling code.
  Calls to the command will not be recorded when content is specified.
class_docstr_tok: ["Context","manager","to","mock","a","system","command",".","The","mock","command","will","be","written","to","a","directory","at","the","front","of","$","PATH",",","taking","precedence","over","any","existing","command","with","the","same","name",".","The","*","python","*","parameter","accepts","a","string","of","code","for","the","command","to","run",",","in","addition","to","the","default","behaviour","of","recording","calls","to","the","command",".","This","will","run","with","the","same","Python","interpreter","as","the","calling","code",",","but","in","a","new","process",".","The","*","content","*","parameter","gives","extra","control",",","by","providing","a","script","which","will","run","with","no","additions",".","On","Unix",",","it","should","start","with","a","shebang","(","e.g",".","``","#","!","\/usr\/bin\/env","python","``",")","specifying","the","interpreter",".","On","Windows",",","it","will","always","be","run","by","the","same","Python","interpreter","as","the","calling","code",".","Calls","to","the","command","will","not","be","recorded","when","content","is","specified","."]
docstr: Make a mock command, producing fixed output when it is run::
  
      t = 'Sat 24 Apr 17:11:58 BST 2021\n'
      with MockCommand.fixed_output('date', t) as mock_date:
          ...
  
  The stdout & stderr strings will be written to the respective streams,
  and the process will exit with the specified numeric status (the default
  of 0 indicates success).
  
  This works with the recording mechanism, so you can check what arguments
  this command was called with.
docstr_tok: ["Make","a","mock","command",",","producing","fixed","output","when","it","is","run",":",":","t","=","'Sat","24","Apr","17:11:58","BST","2021\\n'","with","MockCommand.fixed_output","(","'date","'",",","t",")","as","mock_date",":","...","The","stdout","&","stderr","strings","will","be","written","to","the","respective","streams",",","and","the","process","will","exit","with","the","specified","numeric","status","(","the","default","of","0","indicates","success",")",".","This","works","with","the","recording","mechanism",",","so","you","can","check","what","arguments","this","command","was","called","with","."]
code: def fixed_output(cls, name, stdout="", stderr="", exit_status=0):
      """Make a mock command, producing fixed output when it is run::
  
          t = 'Sat 24 Apr 17:11:58 BST 2021\\n'
          with MockCommand.fixed_output('date', t) as mock_date:
              ...
  
      The stdout & stderr strings will be written to the respective streams,
      and the process will exit with the specified numeric status (the default
      of 0 indicates success).
  
      This works with the recording mechanism, so you can check what arguments
      this command was called with.
      """
      return cls(
          name,
          python=_output_template.format(stdout, stderr, exit_status),
      )
  
file_path: catboost/contrib/python/testpath/py3/testpath/commands.py
imports: import contextlib
  import json
  import os
  import shutil
  import sys
  import tempfile
label_desc: Use image node_id 2 for calling the MockCommand obj's underlying member method code with example usage: obj.fixed_output(cls, name, stdout, stderr, exit_status) and returns: cls