Public Member Functions | Private Attributes | List of all members
tests._runner.CaptureFile Class Reference
Inheritance diagram for tests._runner.CaptureFile:
Inheritance graph
[legend]

Public Member Functions

def __enter__ (self)
 
def __exit__ (self, type, value, traceback)
 
def __init__ (self, fd)
 
def close (self)
 
def output (self)
 
def start (self)
 
def stop (self)
 
def write_bypass (self, value)
 

Private Attributes

 _into_file
 
 _redirected_fd
 
 _saved_fd
 

Detailed Description

A context-managed file to redirect output to a byte array.

  Use by invoking `start` (`__enter__`) and at some point invoking `stop`
  (`__exit__`). At any point after the initial call to `start` call `output` to
  get the current redirected output. Note that we don't currently use file
  locking, so calling `output` between calls to `start` and `stop` may muddle
  the result (you should only be doing this during a Python-handled interrupt as
  a last ditch effort to provide output to the user).

  Attributes:
_redirected_fd (int): File descriptor of file to redirect writes from.
_saved_fd (int): A copy of the original value of the redirected file
  descriptor.
_into_file (TemporaryFile or None): File to which writes are redirected.
  Only non-None when self is started.

Definition at line 35 of file _runner.py.

Constructor & Destructor Documentation

◆ __init__()

def tests._runner.CaptureFile.__init__ (   self,
  fd 
)

Definition at line 53 of file _runner.py.

Member Function Documentation

◆ __enter__()

def tests._runner.CaptureFile.__enter__ (   self)

Definition at line 89 of file _runner.py.

◆ __exit__()

def tests._runner.CaptureFile.__exit__ (   self,
  type,
  value,
  traceback 
)

Definition at line 93 of file _runner.py.

◆ close()

def tests._runner.CaptureFile.close (   self)
Close any resources used by self not closed by stop().

Definition at line 96 of file _runner.py.

◆ output()

def tests._runner.CaptureFile.output (   self)
Get all output from the redirected-to file if it exists.

Definition at line 58 of file _runner.py.

◆ start()

def tests._runner.CaptureFile.start (   self)
Start redirection of writes to the file descriptor.

Definition at line 66 of file _runner.py.

◆ stop()

def tests._runner.CaptureFile.stop (   self)
Stop redirection of writes to the file descriptor.

Definition at line 71 of file _runner.py.

◆ write_bypass()

def tests._runner.CaptureFile.write_bypass (   self,
  value 
)
Bypass the redirection and write directly to the original file.

    Arguments:
      value (str): What to write to the original file.

Definition at line 76 of file _runner.py.

Member Data Documentation

◆ _into_file

tests._runner.CaptureFile._into_file
private

Definition at line 56 of file _runner.py.

◆ _redirected_fd

tests._runner.CaptureFile._redirected_fd
private

Definition at line 54 of file _runner.py.

◆ _saved_fd

tests._runner.CaptureFile._saved_fd
private

Definition at line 55 of file _runner.py.


The documentation for this class was generated from the following file:


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:52