class_docstr: Run Python tests using IPython.testing.iptest
class_docstr_tok: ["Run","Python","tests","using","IPython.testing.iptest"]
code: def setup(self):
      ipydir = TemporaryDirectory()
      self.dirs.append(ipydir)
      self.env["IPYTHONDIR"] = ipydir.name
      self.workingdir = workingdir = TemporaryDirectory()
      self.dirs.append(workingdir)
      self.env["IPTEST_WORKING_DIR"] = workingdir.name
      # This means we won't get odd effects from our own matplotlib config
      self.env["MPLCONFIGDIR"] = workingdir.name
      # For security reasons (http://bugs.python.org/issue16202), use
      # a temporary directory to which other users have no access.
      self.env["TMPDIR"] = workingdir.name
  
      # Add a non-accessible directory to PATH (see gh-7053)
      noaccess = os.path.join(self.workingdir.name, "_no_access_")
      self.noaccess = noaccess
      os.mkdir(noaccess, 0)
  
      PATH = os.environ.get("PATH", "")
      if PATH:
          PATH = noaccess + os.pathsep + PATH
      else:
          PATH = noaccess
      self.env["PATH"] = PATH
  
      # From options:
      if self.options.xunit:
          self.add_xunit()
      if self.options.coverage:
          self.add_coverage()
      self.env["IPTEST_SUBPROC_STREAMS"] = self.options.subproc_streams
      self.cmd.extend(self.options.extra_args)
  
imports: from __future__ import print_function
  import argparse
  import json
  import multiprocessing.pool
  import os
  import stat
  import re
  import requests
  import shutil
  import signal
  import sys
  import subprocess
  import time
  from .iptest import have, test_group_names, test_sections, StreamCapturer, test_for
  from IPython.utils.path import compress_user
  from IPython.utils.py3compat import bytes_to_str
  from IPython.utils.sysinfo import get_sys_info
  from IPython.utils.tempdir import TemporaryDirectory
  from IPython.utils.text import strip_ansi
label_desc: Use image node_id 2 for calling the PyTestController obj's underlying member method code with example usage: obj.setup() without return types