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: Assert that the mock command has been called at least once.
  
  If args is passed, also check that it was called at least once with the
  given arguments (not including the command name), e.g.::
  
      with MockCommand('rsync') as mock_rsync:
          function_to_test()
  
      mock_rsync.assert_called(['/var/log', 'backup-server:logs'])
  
  This won't work if you used the *content* parameter to alter what
  the mocked command does.
docstr_tok: ["Assert","that","the","mock","command","has","been","called","at","least","once",".","If","args","is","passed",",","also","check","that","it","was","called","at","least","once","with","the","given","arguments","(","not","including","the","command","name",")",",","e.g",".",":",":","with","MockCommand","(","'rsync","'",")","as","mock_rsync",":","function_to_test","(",")","mock_rsync.assert_called","(","[","'\/var\/log","'",",","'backup-server",":","logs","'","]",")","This","wo","n't","work","if","you","used","the","*","content","*","parameter","to","alter","what","the","mocked","command","does","."]
code: def assert_called(self, args=None):
      """Assert that the mock command has been called at least once.
  
      If args is passed, also check that it was called at least once with the
      given arguments (not including the command name), e.g.::
  
          with MockCommand('rsync') as mock_rsync:
              function_to_test()
  
          mock_rsync.assert_called(['/var/log', 'backup-server:logs'])
  
      This won't work if you used the *content* parameter to alter what
      the mocked command does.
      """
      calls = self.get_calls()
      assert calls != [], "Command %r was not called" % self.name
  
      if args is not None:
          if not any(args == c["argv"][1:] for c in calls):
              msg = [
                  "Command %r was not called with specified args (%r)"
                  % (self.name, args),
                  "It was called with these arguments: ",
              ]
              for c in calls:
                  msg.append("  %r" % c["argv"][1:])
              raise AssertionError("\n".join(msg))
  
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 8 for calling the MockCommand obj's underlying member method code with example usage: obj.assert_called(args) without return types