
    ^hy                        S r SSKrSSKrSSKrSSKrSSKrSSKJr  SSKJr  SSK	J
r
Jr  S rS"S jrS"S	 jrS
 rS r\" \R"                  S:H  S5      r\" \R"                  R'                  S5      S5      r\" \R"                  S:H  S5      r\" \R"                  S:g  S5      r\" \R"                  R'                  S5      (       + S5      r\R"                  S;  =(       a    \R0                  R3                  SS5      S:H  rSr\" \\5      rS r\" S5      r\" S5      rS r  \RB                  " SS9r"Sr#\"RI                  5         \" \#S 5      r&S! r'g! \% a    Sr# Nf = f)#a  Decorators for labeling test objects.

Decorators that merely return a modified version of the original function
object are straightforward.  Decorators that return a new function object need
to use nose.tools.make_decorator(original_function)(decorator) in returning the
decorator, in order to preserve metadata such as function name, setup and
teardown functions and so on - see nose.tools for more information.

This module provides a set of useful decorators meant to be ready to use in
your own tests.  See the bottom of the file for the ready-made ones, and if you
find yourself writing a new one that may be of generic use, add it here.

Included decorators:


Lightweight testing that remains unittest-compatible.

- An @as_unittest decorator can be used to tag any normal parameter-less
  function as a unittest TestCase.  Then, both nose and normal unittest will
  recognize it as such.  This will make it easier to migrate away from Nose if
  we ever need/want to while maintaining very lightweight tests.

NOTE: This file contains IPython-specific decorators. Using the machinery in
IPython.external.decorators, we import either numpy.testing.decorators if numpy is
available, OR use equivalent code in IPython.external._decorators, which
we've copied verbatim from numpy.

    N)import_module)	decorator   )	ipdoctestipdocstringc                 b   ^   " U 4S jS[         R                  5      nT R                  Ul        U$ )zDDecorator to make a simple function into a normal test via unittest.c                   "   > \ rS rSrU 4S jrSrg)as_unittest.<locals>.Tester5   c                    > T" 5         g N )selffuncs    T/home/james-whalen/.local/lib/python3.13/site-packages/IPython/testing/decorators.pytest as_unittest.<locals>.Tester.test6   s    F    r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__)r   s   r   Testerr
   5   s    	 	r   r   )unittestTestCaser   )r   r   s   ` r   as_unittestr   3   s'    ""  mmFOMr   c                 t    Uc  SnSSK n[        U [        5      (       d   eUR                  R	                  XS9$ )a  Make function raise SkipTest exception if skip_condition is true

Parameters
----------

skip_condition : bool or callable
  Flag to determine whether to skip test. If the condition is a
  callable, it is used at runtime to dynamically make the decision. This
  is useful for tests that may require costly imports, to delay the cost
  until the test suite is actually executed.
msg : string
  Message to give on raising a SkipTest exception.

Returns
-------
decorator : function
  Decorator, which, when applied to a function, causes SkipTest
  to be raised when the skip_condition was True, and the function
  to be called normally otherwise.
Nz#Test skipped due to test condition.r   reason)pytest
isinstanceboolmarkskipif)skip_conditionmsgr!   s      r   r%   r%   @   s<    * {3nd++++;;n99r   c                 h    U (       a   [        U [        5      (       d  [        S5      e[        SU 5      $ )a1  Decorator factory - mark a test function for skipping from test suite.

Parameters
----------
  msg : string
    Optional message to be added.

Returns
-------
   decorator : function
     Decorator, which, when applied to a function, causes SkipTest
     to be raised, with the optional message added.
  zSinvalid object passed to `@skip` decorator, did you meant `@skip()` with brackets ?T)r"   str
ValueErrorr%   )r'   s    r   skipr+   `   s2     :c3'' ; < 	<$r   c                 $    [        U (       + U5      $ )z0The reverse from skipif, see skipif for details.)r%   )	conditionr'   s     r   onlyifr.   t   s     i-%%r   c                 H     [        U 5      nSnU$ ! [         a    Sn U$ f = f)zCan module be imported?  Returns true if module does NOT import.

This is used to make a decorator to skip tests that require module to be
available, but delay the 'import numpy' to test execution time.
FT)r   ImportError)modulemodmod_not_avails      r   module_not_availabler4   {   s:    F#   s    !!win32z$This test does not run under Windowslinuxz"This test does not run under Linuxdarwinz!This test does not run under OS Xz!This test only runs under WindowszThis test only runs under Linux)r7   r5   DISPLAY z.Skipped under *nix when X11/XOrg not availablec                 2    [        [        U 5      SU -  5      $ )NzThis test requires %s)r%   r4   )r2   s    r   <lambda>r;      s    6"6s";=TWZ=Z[r   numpy
matplotlibc                     U $ r   r   )fs    r   r;   r;      s    ar   u   tmp€)prefixTFzCThis test is only applicable where we can use unicode in filenames.c                      [         R                  R                  SS5      b   S5       eU  HC  nSU S3n[        R                  " U5      (       a  M&  SSKnUR                  R                  US9s  $    [        $ )zF
Decorator to skip test when at least one of `commands` is not found.
IPTEST_WORKING_DIRNz#iptest deprecated since IPython 8.0z This test runs only if command 'z' is installedr   r   )	osenvirongetshutilwhichr!   r$   r+   	null_deco)commandscmdr    r!   s       r   onlyif_cmds_existrK      st    
 	

+T2:-,-:3C5G||C  ;;##6#22  r   r   )(__doc__rC   rF   systempfiler   	importlibr   r   
ipunittestr   r   r   r%   r+   r.   r4   platform
skip_win32
startswith
skip_linuxskip_osxskip_if_not_win32skip_if_not_linuxrD   rE   _x11_skip_cond_x11_skip_msgskip_if_no_x11skip_withoutskipif_not_numpyskipif_not_matplotlibrH   NamedTemporaryFiler?   unicode_pathscloseUnicodeEncodeErroronlyif_unicode_pathsrK   r   r   r   <module>rc      s  @ 
  
   #  /:@(&& CLLG+:<
CLL++G48:
#,,(*+NO 3<<72>@ s||66w??<>  ,,&99 6**..B/25 @6
 \( $\2  	##95A MGGIm /M O   Ms    E EE