
    `jz                         d Z ddlZddlZddlZddlZddlZddlZddlmZ ddlm	Z	 ddlm
Z
  G d dej                  Zej        d             Zej        Zej        Zej        ZdS )	z"Utilities for Python Fire's tests.    N)mock)core)tracec                   V    e Zd ZdZej        dd            Zej        dd            ZdS )	BaseTestCasez'Shared test case for Python Fire tests..*Tc              #     K   t          j                    }t          j                    }	 t          j                            t
          d|          5  t          j                            t
          d|          5  dV  ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   |sbt
          j                            |                                           t
          j	                            |                                           nj# |sct
          j                            |                                           t
          j	                            |                                           w w xY wd||fd||ffD ]w\  }}}|                                }	||	rt          |d|	          3t          j        ||	t          j        t          j        z            st          |d|	d|          xdS )a  Asserts that the context generates stdout and stderr matching regexps.

    Note: If wrapped code raises an exception, stdout and stderr will not be
      checked.

    Args:
      stdout: (str) regexp to match against stdout (None will check no stdout)
      stderr: (str) regexp to match against stderr (None will check no stderr)
      capture: (bool, default True) do not bubble up stdout or stderr

    Yields:
      Yields to the wrapped context.
    stdoutstderrNz: Expected no output. Got: z: Expected z
 to match )ioStringIOr   patchobjectsysr
   writegetvaluer   AssertionErrorresearchDOTALL	MULTILINE)
selfr
   r   capture	stdout_fp	stderr_fpnameregexpfpvalues
             R/home/jworkman/hermes-web-chat/venv/lib/python3.11/site-packages/fire/testutils.pyassertOutputMatchesz BaseTestCase.assertOutputMatches    sz      II/:S(I66  ZsHi88 	 	
%%%	 	 	 	 	 	 	 	 	 	 	 	 	 	 	                /
++--...
++--...  /
++--...
++--..../ '	:&	:< 
6 
6fbkkmme	 	. $ee - . . .	. y	BL(@AA 	6 $eeeVV 5 6 6 6	6
6 
6sT   &D 'B7B<BB	BB	BD B##D &B#'D A'E6c           	   #     K   |                      |          5  |                     t          j                  5  	 dV  nb# t          j        $ rP}|j        |k    rt          d|j        d|          |                     |j        t          j                    d}~ww xY w	 ddd           n# 1 swxY w Y   ddd           dS # 1 swxY w Y   dS )a^  Asserts that a FireExit error is raised in the context.

    Allows tests to check that Fire's wrapper around SystemExit is raised
    and that a regexp is matched in the output.

    Args:
      code: The status code that the FireExit should contain.
      regexp: stdout must match this regex.

    Yields:
      Yields to the wrapped context.
    )r   NzIncorrect exit code: z != )	r!   assertRaisesr   FireExitcoder   assertIsInstancer   	FireTrace)r   r%   r   excs       r    assertRaisesFireExitz!BaseTestCase.assertRaisesFireExitF   st      
	!	!	!	0	0 	 	T]++  	
%%%%} 	 	 	X ."%(((DD"2 3 3 3


	5?
;
;
;
	               	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sW    CB/A B/ BABBB/#C/B3	3C6B3	7CCCN)r   r   T)r   )__name__
__module____qualname____doc__
contextlibcontextmanagerr!   r)        r    r   r      sa        //#6 #6 #6 #6J      r1   r   c              #      K   t          j                    }t          j        |            	 | V  t          j        |           dS # t          j        |           w xY w)z>Context manager to mock a directory change and revert on exit.N)osgetcwdchdir)	directorycwdirs     r    ChangeDirectoryr8   `   sT       )++%(9
OOOHUOOOOOBHUOOOOs   A A)r-   r.   r   r3   r   r   unittestr   firer   r   TestCaser   r/   r8   mainskipskipIfr0   r1   r    <module>r?      s    ) (     				 				 				 



                   @ @ @ @ @8$ @ @ @F    }}	r1   