
    wgY_                       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ZddlZddl	Z	ddl
m
Z
 ddlmZ ddlZddlmZm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ZddlmZ ddlmZ ddlmZ dd	lmZ dd
l m!Z! ejD                  dk(  Z# ejH                  dd      Z%g dZ&g dZ' G d de(      Z) G d de(      Z* G d de(      Z+d@dZ,e,e_,        d Z-e#re-e_.        d Z/d Z0dAdZ1ed        Z2ddejf                  ddfdZ4	 	 	 dBd Z5ddd!d"Z6dd#dddddddddddddddd$d%Z7ddd!d&Zd' Z8d( Z9 ejt                  d)      Z;dCd*Z<dd+l=m>Z>  e>d,d-      Z?ddddddddd ej                         dfd.ZA G d/ d0      ZB G d1 d2      ZC G d3 d4e      ZD G d5 d6e      ZEg d7ZFeFD ]  ZGd8eGz   ZHd9eGz   ZI eJeEeI eKeeH               G d: d;ej                        ZM G d< d=      ZN G d> d?eN      ZOy)DaF  
This is our testing framework.

Goals:

* it should be compatible with py.test and operate very similarly
  (or identically)
* does not require any external dependencies
* preferably all the functionality should be in this file only
* no magic, just import the test file and execute the test functions, that's it
* portable

    N)fnmatch)default_timer)DocTestFinderDocTestRunner)contextmanager)unwrap)clear_cache)import_module)GROUND_TYPESntCI)d0*x?g_vOf?g_Q{?/nR?a2U0*C?gw?UN@s?gHPsr?Mbp?gp_Q?g_Q[?_Le?r   -C6j?-C6Z?~jtX?-C6:?r   r   ǺV?g 	??߾?gJY8?g_vO~?g"uq?gS!uq{?g0*?r   g ~:p?gZӼ?ggj+?a2U0*3?r   r   r   _LU?r   -C6J?ǺF?r   gPkw?r   r   爅ZӼt?Mb`?r   Mb@?g䃞ͪϕ?ga2U0*s?r   a2U0*S?r   a2U0*c?r   r   r    r   gI+?ga+ey?r   gJ4a?nt?r   r   r   r   gŏ1w-!_?~jth?g/nr?g_vOv?+eXw?r#   r   r   gH}M?r   r!   r   g2%䃎?g]K=?gŏ1w-!?g	^)p?r"   gS㥋?gǘ?gׁsF?g9m4?gw-!l?gHP?r   r   r   r   gqo?r"   r    r   r$   gy&1?r   )(g"u?r   gZӼ?r   r   r    r   r   r   gǘ?gׁsF?g r?gJ+?r    g-C6z?r   r   r   r   r   gy):?r"   gF%uk?r%   r    r   gMbP?g;Onr?g&S?r   r    g8gDio?r   g}?5^I?gS?gW/'?r   r   r   g_)Ǻ?c                       e Zd Zy)SkippedN__name__
__module____qualname__     [/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/testing/runtests.pyr'   r'   W       r-   r'   c                       e Zd Zy)TimeOutErrorNr(   r,   r-   r.   r1   r1   Z   r/   r-   r1   c                       e Zd Zy)DependencyErrorNr(   r,   r-   r.   r3   r3   ]   r/   r-   r3   c                 6    t        j                  d|dz  |       S )z
    Add the given number of space characters to the beginning of
    every non-blank line in ``s``, and return the result.
    If the string ``s`` is Unicode, it is encoded using the stdout
    encoding and the ``backslashreplace`` error handler.
    z
(?m)^(?!$) )resub)sindents     r.   _indentr:   a   s     66,s
A..r-   c                     | j                   j                  ||| j                        }|j                  d      j	                  dd      } || j                  ||      |z          y)z/
    Report that the given example failed.
    raw_unicode_escapeutf8ignoreN)_checkeroutput_differenceoptionflagsencodedecode_failure_header)selfouttestexamplegotr8   s         r.   _report_failurerJ   q   sX     	''d6F6FGA	%&--fh?AT7+a/0r-   c                 r   g }t        |       D ]  \  }}t        j                  j                  |j	                  d       }t
        j                  dk(  r5|j                  d      }|dk7  r||dz      dk7  r|d|dz    dz   ||dz   d z   }|j                  t        j                  j                  |              |S )z
    Converts a list of '/' separated paths into a list of
    native (os.sep separated) paths and converts to lowercase
    if the system is case insensitive.
    /win32:   \N)
	enumerateospathjoinsplitsysplatformfindappendnormcase)lstnewlstirvposs        r.   convert_to_native_pathsra   ~   s     F3 ,2WW\\288C=)<<7"''#,CbycAg;$&HS1W,r#'(|;Bbgg&&r*+, Mr-   c                  @   t         j                  j                  t              } t         j                  j	                  t         j                  j                  |       dd      }t         j                  j                  |      }t         j                  j                  |      S )z
    Returns the root SymPy directory and set the global value
    indicating whether the system is case sensitive or not.
    z..)rS   rT   abspath__file__rU   dirnamenormpathr[   )	this_file	sympy_dirs     r.   get_sympy_dirri      sb    
 )IRWW__Y7tDI  +I77I&&r-   Tc                     ddl m} ddlm} dd l mc m} ddlm} d|_         |d      }|j                  }| rd|_	         |d       ||fS )Nr   )init_printingpprint_use_unicode
stringpictTF)pretty_print)
sympy.interactive.printingrk   sympy.printing.pretty.prettyrm   interactiveprintingsympy.printing.prettyro   	NO_GLOBAL_GLOBAL_WRAP_LINE)disable_line_wraprk   rm   interactive_printingro   use_unicode_prevwrap_line_prevs          r.   setup_pprintr|      sV    8?==0 &*" *%0  11N',
$ u%^++r-   c               #      K   t        j                         5  t        j                  ddt        d       d ddd       y# 1 sw Y   yxY ww)a+  Context manager to make DeprecationWarning raise an error

    This is to catch SymPyDeprecationWarning from library code while running
    tests and doctests. It is important to use this context manager around
    each individual test/doctest in case some tests modify the warning
    filters.
    errorz.*zsympy.*)moduleN)warningscatch_warningsfilterwarningsDeprecationWarningr,   r-   r.   raise_on_deprecatedr      s@      
	 	 	" /A)T  s   A"A	AAAr,   zsympy.testing.runtestsFc                 4   t               }t        j                  |dgt        j                  t        j                  |      }|j                          |j                  dk7  ryt        j                  d      }|s0t        t        j                  d            t        j                  d<   n|sy|xs i }d|d| d	| d
t        |      dt        |      d}		 t        j                  |dd|	g|      }|j                          |t        j                  d= |j                  S |t        j                  d<   |j                  S # t        $ r |j                          Y Yw xY w# |t        j                  d= n|t        j                  d<   |j                  c cY S xY w)a	  
    Run a function in a Python subprocess with hash randomization enabled.

    If hash randomization is not supported by the version of Python given, it
    returns False.  Otherwise, it returns the exit value of the command.  The
    function is passed to sys.exit(), so the return value of the function will
    be the return value.

    The environment variable PYTHONHASHSEED is used to seed Python's hash
    randomization.  If it is set, this function will return False, because
    starting a new subprocess is unnecessary in that case.  If it is not set,
    one is set at random, and the tests are run.  Note that if this
    environment variable is set when Python starts, hash randomization is
    automatically enabled.  To force a subprocess to be created even if
    PYTHONHASHSEED is set, pass ``force=True``.  This flag will not force a
    subprocess in Python versions that do not support hash randomization (see
    below), because those versions of Python do not support the ``-R`` flag.

    ``function`` should be a string name of a function that is importable from
    the module ``module``, like "_test".  The default for ``module`` is
    "sympy.testing.runtests".  ``function_args`` and ``function_kwargs``
    should be a repr-able tuple and dict, respectively.  The default Python
    command is sys.executable, which is the currently running Python command.

    This function is necessary because the seed for hash randomization must be
    set by the environment variable before Python starts.  Hence, in order to
    use a predetermined seed for tests, we must start Python in a separate
    subprocess.

    Hash randomization was added in the minor Python versions 2.6.8, 2.7.3,
    3.1.5, and 3.2.3, and is enabled by default in all Python versions after
    and including 3.3.0.

    Examples
    ========

    >>> from sympy.testing.runtests import (
    ... run_in_subprocess_with_hash_randomization)
    >>> # run the core tests in verbose mode
    >>> run_in_subprocess_with_hash_randomization("_test",
    ... function_args=("core",),
    ... function_kwargs={'verbose': True}) # doctest: +SKIP
    # Will return 0 if sys.executable supports hash randomization and tests
    # pass, 1 if they fail, and False if it does not support hash
    # randomization.

    z-RV)stdoutstderrcwdr   FPYTHONHASHSEEDl        zimport sys; from z import z
;sys.exit(z(*z, **z))z-Rz-c)r   )ri   
subprocessPopenPIPESTDOUTcommunicate
returncoderS   getenvstrrandom	randrangeenvironreprKeyboardInterruptwait)
functionfunction_argsfunction_kwargscommandr   forcer   p	hash_seedcommandstrings
             r.   )run_in_subprocess_with_hash_randomizationr      s\   f /C 	'5)*// * 1 1s	<AMMO||q		*+I'*6+;+;E+B'C

#$%+O h$}2E?+-MgtT=AsK	 

+, || ,5BJJ'(||  	
 

+,+4BJJ'(||s$   +E   EE EE 6Fc                    d}|xs i }|xs i }|xs ddi}	 t        | i |sd}t                t        |i |sd}t                t        j                  j                  d       ddlm}  ||i |sd}|ryt        j                  d       y# t        $ r- t                t        d	       t        j                  d       Y yw xY w)
a  
    Run all tests.

    Right now, this runs the regular tests (bin/test), the doctests
    (bin/doctest), and the examples (examples/all.py).

    This is what ``setup.py test`` uses.

    You can pass arguments and keyword arguments to the test functions that
    support them (for now, test,  doctest, and the examples). See the
    docstrings of those functions for a description of the available options.

    For example, to run the solvers tests with colors turned off:

    >>> from sympy.testing.runtests import run_all_tests
    >>> run_all_tests(test_args=("solvers",),
    ... test_kwargs={"colors:False"}) # doctest: +SKIP

    TquietFexamplesr   )run_examplesNrP   DO *NOT* COMMIT!)
rG   printdoctestrW   rT   rZ   allr   exitr   )	test_argstest_kwargsdoctest_argsdoctest_kwargsexamples_argsexamples_kwargstests_successfulr   s           r.   run_all_testsr     s    , #K#)rN%8'4OY.+.  % 	77$ 	
#$]>o>$ HHQK  !s   AB 8B 3CC)r   rerunc                    fd}| rEt        dd      D ]5  } ||       t        d||      }|du r nt        |       }|r|dk(  s3|c S  t        dd      D ]*  } ||       t        t        |i |       }|r|dk(  s(|c S  y)a  
    Run tests in the specified test_*.py files.

    Tests in a particular test_*.py file are run if any of the given strings
    in ``paths`` matches a part of the test file's path. If ``paths=[]``,
    tests in all test_*.py files are run.

    Notes:

    - If sort=False, tests are run in random order (not default).
    - Paths can be entered in native system format or in unix,
      forward-slash format.
    - Files that are on the blacklist can be tested by providing
      their path; they are only excluded if no paths are given.

    **Explanation of test results**

    ======  ===============================================================
    Output  Meaning
    ======  ===============================================================
    .       passed
    F       failed
    X       XPassed (expected to fail but passed)
    f       XFAILed (expected to fail and indeed failed)
    s       skipped
    w       slow
    T       timeout (e.g., when ``--timeout`` is used)
    K       KeyboardInterrupt (when running the slow tests with ``--slow``,
            you can interrupt one of them without killing the test runner)
    ======  ===============================================================


    Colors have no additional meaning and are used just to facilitate
    interpreting the output.

    Examples
    ========

    >>> import sympy

    Run all tests:

    >>> sympy.test()    # doctest: +SKIP

    Run one file:

    >>> sympy.test("sympy/core/tests/test_basic.py")    # doctest: +SKIP
    >>> sympy.test("_basic")    # doctest: +SKIP

    Run all tests in sympy/functions/ and some particular file:

    >>> sympy.test("sympy/core/tests/test_basic.py",
    ...        "sympy/functions")    # doctest: +SKIP

    Run all tests in sympy/core and sympy/utilities:

    >>> sympy.test("/core", "/util")    # doctest: +SKIP

    Run specific test from a file:

    >>> sympy.test("sympy/core/tests/test_basic.py",
    ...        kw="test_equality")    # doctest: +SKIP

    Run specific test from any file:

    >>> sympy.test(kw="subs")    # doctest: +SKIP

    Run the tests with verbose mode on:

    >>> sympy.test(verbose=True)    # doctest: +SKIP

    Do not sort the test output:

    >>> sympy.test(sort=False)    # doctest: +SKIP

    Turn on post-mortem pdb:

    >>> sympy.test(pdb=True)    # doctest: +SKIP

    Turn off colors:

    >>> sympy.test(colors=False)    # doctest: +SKIP

    Force colors, even when the output is not to a terminal (this is useful,
    e.g., if you are piping to ``less -r`` and you still want colors)

    >>> sympy.test(force_colors=False)    # doctest: +SKIP

    The traceback verboseness can be set to "short" or "no" (default is
    "short")

    >>> sympy.test(tb='no')    # doctest: +SKIP

    The ``split`` option can be passed to split the test run into parts. The
    split currently only splits the test files, though this may change in the
    future. ``split`` should be a string of the form 'a/b', which will run
    part ``a`` of ``b``. For instance, to run the first half of the test suite:

    >>> sympy.test(split='1/2')  # doctest: +SKIP

    The ``time_balance`` option can be passed in conjunction with ``split``.
    If ``time_balance=True`` (the default for ``sympy.test``), SymPy will attempt
    to split the tests such that each split takes equal time.  This heuristic
    for balancing is based on pre-recorded test data.

    >>> sympy.test(split='1/2', time_balance=True)  # doctest: +SKIP

    You can disable running the tests in a separate subprocess using
    ``subprocess=False``.  This is done to support seeding hash randomization,
    which is enabled by default in the Python versions where it is supported.
    If subprocess=False, hash randomization is enabled/disabled according to
    whether it has been enabled or not in the calling Python process.
    However, even if it is enabled, the seed cannot be printed unless it is
    called from a new Python process.

    Hash randomization was added in the minor Python versions 2.6.8, 2.7.3,
    3.1.5, and 3.2.3, and is enabled by default in all Python versions after
    and including 3.3.0.

    If hash randomization is not supported ``subprocess=False`` is used
    automatically.

    >>> sympy.test(subprocess=False)     # doctest: +SKIP

    To set the hash randomization seed, set the environment variable
    ``PYTHONHASHSEED`` before running the tests.  This can be done from within
    Python using

    >>> import os
    >>> os.environ['PYTHONHASHSEED'] = '42' # doctest: +SKIP

    Or from the command line using

    $ PYTHONHASHSEED=42 ./bin/test

    If the seed is not set, a random seed will be chosen.

    Note that to reproduce the same hash values, you must use both the same seed
    as well as the same architecture (32-bit vs. 64-bit).

    c                 4    | z
  rt        d| z
  z        S d S Nzrerun %dr   r^   r   s    r.   <lambda>ztest.<locals>.<lambda>  '    #(7 !&jE!G&< = 04 r-   rO   _testr   r   Fr   N)ranger   boolr   r   r   pathskwargsprint_counterr^   retvals    `      r.   rG   rG   W  s    ^6M ub"% 		A!;G&+VECe|3i-C!q&
		 5"b! aue.v.//a1fJ	r-   short)verbosetbkwpdbcolorsforce_colorssortseedtimeoutfail_on_timeoutslowenhance_assertsrV   time_balance	blacklistfast_thresholdslow_thresholdc           	         |xs d}t        |t              r|f}|}|t        j                  d      }t        r|du rd}d}	t        rt        |      dgz   }t        |      }t        | ||||      }g }|D ]2  }d	|v r|j                  d	d
      \  }}||fz  }|j                  |       4 |}t        ||||||      }|j                  d      }|D cg c]  t        fd|D              s }}t        |      dk(  r|}n]t        |      }g }|D ]K  t        j                  j!                        }|D ]%  }|v st#        ||      s|j                          K M d}|r|
rt$        }nt&        }|rt)        |||      }|j*                  j-                  |       t/        |j1                  |||
||	             S c c}w )a  
    Internal function that actually runs the tests.

    All keyword arguments from ``test()`` are passed to this function except for
    ``subprocess``.

    Returns 0 if tests passed and 1 if they failed.  See the docstring of
    ``test()`` for more information.
    r,   Ni FiS  Tzsympy/plotting/pygletplot/tests)r   r   r   r   rV   ::rP   )r   r   sympyc              3   &   K   | ]  }|v  
 y wNr,   .0bfs     r.   	<genexpr>z_test.<locals>.<genexpr>-       !<Q!q&!<   r   )density)r   r   r   r   r   )
isinstancer   r   r   ON_CIlistra   PyTestReporterrV   rZ   
SymPyTestsget_test_filesanylenrS   rT   basenamer   SPLIT_DENSITY_SLOWSPLIT_DENSITY
split_list
_testfilesextendintrG   )r   r   r   r   r   r   r   r   r   r   r   r   rV   r   r   r   r   r   post_mortemr_pathsrT   _kwt
test_filesr   not_blacklistedmatchedr   r   r   s                            `     r.   r   r     s    
rB"cUK|	*E!O'H&II	'	2Iw2f!	0A F 4<

4+ID#3&LBd	
 E1b+t"0"0	2A !!'*J", >Q!!<)!<<  >O > 5zQ!'.  	Aww''*H 6WXq1NN1%	 G(G#GWeW=LL 166tW4'  J J K K7>s   F?c                    fd}| rEt        dd      D ]5  } ||       t        d||      }|du r nt        |       }|r|dk(  s3|c S  t        dd      D ]*  } ||       t        t        |i |       }|r|dk(  s(|c S  y)a  
    Runs doctests in all \*.py files in the SymPy directory which match
    any of the given strings in ``paths`` or all tests if paths=[].

    Notes:

    - Paths can be entered in native system format or in unix,
      forward-slash format.
    - Files that are on the blacklist can be tested by providing
      their path; they are only excluded if no paths are given.

    Examples
    ========

    >>> import sympy

    Run all tests:

    >>> sympy.doctest() # doctest: +SKIP

    Run one file:

    >>> sympy.doctest("sympy/core/basic.py") # doctest: +SKIP
    >>> sympy.doctest("polynomial.rst") # doctest: +SKIP

    Run all tests in sympy/functions/ and some particular file:

    >>> sympy.doctest("/functions", "basic.py") # doctest: +SKIP

    Run any file having polynomial in its name, doc/src/modules/polynomial.rst,
    sympy/functions/special/polynomials.py, and sympy/polys/polynomial.py:

    >>> sympy.doctest("polynomial") # doctest: +SKIP

    The ``split`` option can be passed to split the test run into parts. The
    split currently only splits the test files, though this may change in the
    future. ``split`` should be a string of the form 'a/b', which will run
    part ``a`` of ``b``. Note that the regular doctests and the Sphinx
    doctests are split independently. For instance, to run the first half of
    the test suite:

    >>> sympy.doctest(split='1/2')  # doctest: +SKIP

    The ``subprocess`` and ``verbose`` options are the same as with the function
    ``test()`` (see the docstring of that function for more information) except
    that ``verbose`` may also be set equal to ``2`` in order to print
    individual doctest lines, as they are being tested.
    c                 4    | z
  rt        d| z
  z        S d S r   r   r   s    r.   r   zdoctest.<locals>.<lambda>}  r   r-   rO   _doctestr   Fr   N)r   r   r   r   r   s    `      r.   r   r   K  s    d6M ub"% 		A!;J&+VECe|3i-C!q&
		 5"b! ax1&122a1fJ	r-   c                     g } | j                  g d       d}t        d|dz         D ]"  }| j                  dt        |      z   dz          $ | j                  g d       t	        d      | j                  g d	       n4t	        d
      | j                  ddg       nddl}|j                  d       t        st	        d      | j                  dg       t	        d      | j                  ddg       t	        d      | j                  dg       t	        d      | j                  dg       t	        d      | j                  ddg       t	        d      | j                  dg       t	        d      | j                  ddg       t	        d      | j                  ddg       | j                  g d       | j                  dg       | j                  g d        t        |       } | S )!z*Get the default blacklist for the doctests)zdoc/src/modules/plotting.rstz4doc/src/modules/physics/mechanics/autolev_parser.rstzsympy/codegen/array_utils.pyzsympy/core/compatibility.pyzsympy/core/trace.pyzsympy/galgebra.pyz,sympy/parsing/autolev/_antlr/autolevlexer.pyz/sympy/parsing/autolev/_antlr/autolevlistener.pyz-sympy/parsing/autolev/_antlr/autolevparser.pyz(sympy/parsing/latex/_antlr/latexlexer.pyz)sympy/parsing/latex/_antlr/latexparser.pyz%sympy/plotting/pygletplot/__init__.pyz!sympy/plotting/pygletplot/plot.pyzsympy/printing/ccode.pyzsympy/printing/cxxcode.pyzsympy/printing/fcode.pyzsympy/testing/randtest.pyzsympy/this.py   rP   z,sympy/parsing/autolev/test-examples/ruletestz.py)zKsympy/parsing/autolev/test-examples/pydy-example-repo/mass_spring_damper.pyzGsympy/parsing/autolev/test-examples/pydy-example-repo/chaos_pendulum.pyzHsympy/parsing/autolev/test-examples/pydy-example-repo/double_pendulum.pyzIsympy/parsing/autolev/test-examples/pydy-example-repo/non_min_pendulum.pynumpyN)z'sympy/plotting/experimental_lambdify.pyzsympy/plotting/plot_implicit.py)examples/advanced/autowrap_integrators.py&examples/advanced/autowrap_ufuncify.pyzexamples/intermediate/sample.py examples/intermediate/mplot2d.py examples/intermediate/mplot3d.py'doc/src/modules/numeric-computation.rstz%doc/src/explanation/best-practices.mdzFdoc/src/tutorials/physics/biomechanics/biomechanical-model-example.rstz7doc/src/tutorials/physics/biomechanics/biomechanics.rst
matplotlibr  r  r   Aggpygletzsympy/plotting/pygletplotaesarazsympy/printing/aesaracode.pyr  cupyjaxantlr4z!sympy/parsing/autolev/__init__.pyz)sympy/parsing/latex/_parse_latex_antlr.pylfortranzsympy/parsing/sym_expr.pyscipyz+doc/src/guides/solving/solve-numerically.mdz#doc/src/guides/solving/solve-ode.md)zsympy/utilities/autowrap.pyr   r   zsympy/conftest.py)zsympy/utilities/tmpfiles.pyzsympy/utilities/pytest.pyzsympy/utilities/runtests.pyz"sympy/utilities/quality_unicode.pyzsympy/utilities/randtest.py)	r   r   rZ   r   r
   r  user   ra   )r   numr^   r  s       r.   _get_doctest_blacklistr    s9   I  * CAs1u ZG#a&PSXXYZ c d
 W% 
 	 &.22  NN5!h'/567X&*5
 	
 V$5
 	 U#5
 	 X&/7
 	
 Z ('
 	 W%91
 	
 W%5=
 	  
   
    (	2Ir-   c                  	   ddl m} ddlm} |j	                  dd      }|j	                  dd      }|j	                  dd      }|j	                  d	d      }|j	                  d
g       }|j	                  dd      }	|j                  t                      t        d      ddl}
|
j                  d       ddl
}d|j                  j                  _        d|j                  j                  _        ddlm}  |        t#        ||	||      }t%        ||      }|j'                  d      }|j                  |j'                  dd             |D cg c]  t)        fd|D              s }}t+        |       dk(  r|}n]t-        |       } g }|D ]K  t.        j0                  j3                        }| D ]%  }|v st5        ||      s|j7                          K M |j9                          |	rt;        ||	      }|j<                  j                  |       |j<                  r|j?                          }nd}|j'                  ddd      }|j'                  ddd      }||z   }|j9                          |D cg c]  t)        fd|D              s }}t+        |       dk(  r|}nRg }|D ]K  t.        j0                  j3                        }| D ]%  }|v st5        ||      s|j7                          K M |	rt;        ||	      }d}|D ]  }t.        j0                  jA                  |      s$tB        jD                  }	 tG               \  }}tI        |ddtJ        jL                  tJ        jN                  z  tJ        jP                  z        }|tB        _"        ddl)m*c m+} d|_,         ||       ||_-        |\  }} | s|xs |}|r>d}d}!|j<                  s|j]                  |!       n|j_                  |!       ta                ||jc                  d      t+        d      z   dz   d }"ta        |"d       |jd                  t+        |"      z
  dz
  }#d | z  }$d |xs d!z  }%ta        d"jg                  |$d|#t+        |$      z
  t+        |%      z
  z  |%g              |s|rta                ta        d#       ti        |      S c c}w c c}w # |tB        _"        ddl)m*c m+} d|_,         |       |_-        w xY w)$a(  
    Internal function that actually runs the doctests.

    All keyword arguments from ``doctest()`` are passed to this function
    except for ``subprocess``.

    Returns 0 if tests passed and 1 if they failed.  See the docstrings of
    ``doctest()`` and ``test()`` for more information.
    r   rl   rn   normalFr   r   Tr   r   rV   Nr  r  )
unset_show)rV   r   r   r   r   )	init_onlyc              3   &   K   | ]  }|v  
 y wr   r,   r   s     r.   r   z_doctest.<locals>.<genexpr>@  r   r   zdoc/srcz*.rstz*.mdc              3   &   K   | ]  }|v  
 y wr   r,   r   s     r.   r   z_doctest.<locals>.<genexpr>j  r   r   utf-8)module_relativeencodingrA   zrst/md doctests start)msgrP   r5   )endz[%s]OK r   )5rr   rm   ru   ro   getr   r  r
   r  r  sympy.externalexternalimporttoolsWARN_OLD_VERSIONWARN_NOT_INSTALLEDsympy.plotting.plotr  r   SymPyDocTestsr   r   r   ra   rS   rT   r   r   rZ   r   r   r   rG   isfilerW   displayhookr|   sympytestfilepdoctestELLIPSISNORMALIZE_WHITESPACEIGNORE_EXCEPTION_DETAILrq   rs   rt   rv   rw   startwrite_centerr   rY   terminal_widthrU   r   )&r   r   rm   ro   r  r   r   r   r   rV   r  r   r  r   r   r   r   r   r   r   r   failedtest_files_rsttest_files_mdfirst_reportrst_fileold_displayhookrz   r{   rF   ry   	rstfailedtestedr  file_idwid	test_filereports&                   `                     r.   r   r     s    @0ZZ%(FjjE*GZZ$'F::ne4L

;+IZZ&E+-. \".u 27ENN/49ENN1 /LweF$0	2Aa A!!'*Ja&&zU&CD", >Q!!<)!<<  >O >
5zQ! (.  	Aww''*H 6WXq1NN1%	 LLNWe,LL  	||VVX %%iE%JN$$Y%$HM-/JOO", >Q!!<)!<<  >O > 5zQ!   	Aww''*H 6WXq1NN1%	 We,L )ww~~h'//	:/;~,n%'$--0M0MM0012C .CO FE-2 */0+9J(	6(&F$-||GGG$NN3'Gx}}W5GDqHIJG's#""S\1A5C&)Iy0D1F"''Cs9~!5F!CDfMO O)\ F !v;e>T>F .CO FE-2 */0+9J(s   R:5R?>AS,S0z([0-9]+)/([1-9][0-9]*)c                    t         j                  |      }|st        d      t        t        |j                               \  }}s&| |dz
  t        |       z  |z  |t        |       z  |z   S t              }D cg c]  }||z  	 c}fd} ||dz
  |z        }	 |||z        }
| t	        |	t        |       z        t	        |
t        |       z         S c c}w )a  
    Splits a list into part a of b

    split should be a string of the form 'a/b'. For instance, '1/3' would give
    the split one of three.

    If the length of the list is not divisible by the number of splits, the
    last split will have more items.

    `density` may be specified as a list.  If specified,
    tests will be balanced so that each split has as equal-as-possible
    amount of mass according to `density`.

    >>> from sympy.testing.runtests import split_list
    >>> a = list(range(10))
    >>> split_list(a, '1/3')
    [0, 1, 2]
    >>> split_list(a, '2/3')
    [3, 4, 5]
    >>> split_list(a, '3/3')
    [6, 7, 8, 9]
    z=split must be a string of the form a/b where a and b are intsrP   c                     | dk  ry| t              k\  ryd}t              D ]  \  }}||z  }|| k\  s n || z
  z
  |z  }|z   t              z  S )zXInterpolate the inverse to the cumulative
        distribution function given by densityr   rP   )sumrR   r   )xcummr^   dfracr   s        r.   density_invzsplit_list.<locals>.density_inv  sw     6G g& 	DAqAIDqy	 TAX!#DCL((r-   )spmatch
ValueErrormapr   groupsr   r=  )lrV   r   mr^   r   totr>  rB  
lower_frachigher_fracs     `        r.   r   r     s    . 	AXYYsAHHJDAq!a%Q"Qs1vXq[11 g,C '(1q3w(G)$ a!eq[)Ja!e$KSCF"#c+c!f*<&=>>- )s   <C)
namedtupleSymPyTestResultszfailed attemptedc                    |r|st        d      t        j                  | |||      \  }} |t        j                  j                  |       }|i }n|j                         }||j                  |       d|vrd|d<   |	rt        j                  ||      }nt        ||      }t               |_        |
j                  |||| d      }|j                  |       |r|j                          t        j                  |t        _        nt        j                  j!                  |       t#        |j$                  |j&                        S )a  
    Test examples in the given file.  Return (#failures, #tests).

    Optional keyword arg ``module_relative`` specifies how filenames
    should be interpreted:

    - If ``module_relative`` is True (the default), then ``filename``
      specifies a module-relative path.  By default, this path is
      relative to the calling module's directory; but if the
      ``package`` argument is specified, then it is relative to that
      package.  To ensure os-independence, ``filename`` should use
      "/" characters to separate path segments, and should not
      be an absolute path (i.e., it may not begin with "/").

    - If ``module_relative`` is False, then ``filename`` specifies an
      os-specific path.  The path may be absolute or relative (to
      the current working directory).

    Optional keyword arg ``name`` gives the name of the test; by default
    use the file's basename.

    Optional keyword argument ``package`` is a Python package or the
    name of a Python package whose directory should be used as the
    base directory for a module relative filename.  If no package is
    specified, then the calling module's directory is used as the base
    directory for module relative filenames.  It is an error to
    specify ``package`` if ``module_relative`` is False.

    Optional keyword arg ``globs`` gives a dict to be used as the globals
    when executing examples; by default, use {}.  A copy of this dict
    is actually used for each docstring, so that each docstring's
    examples start with a clean slate.

    Optional keyword arg ``extraglobs`` gives a dictionary that should be
    merged into the globals that are used to execute examples.  By
    default, no extra globals are used.

    Optional keyword arg ``verbose`` prints lots of stuff if true, prints
    only failures if false; by default, it's true iff "-v" is in sys.argv.

    Optional keyword arg ``report`` prints a summary at the end when true,
    else prints nothing at the end.  In verbose mode, the summary is
    detailed, else very brief (in fact, empty if all tests passed).

    Optional keyword arg ``optionflags`` or's together module constants,
    and defaults to 0.  Possible values (see the docs for details):

    - DONT_ACCEPT_TRUE_FOR_1
    - DONT_ACCEPT_BLANKLINE
    - NORMALIZE_WHITESPACE
    - ELLIPSIS
    - SKIP
    - IGNORE_EXCEPTION_DETAIL
    - REPORT_UDIFF
    - REPORT_CDIFF
    - REPORT_NDIFF
    - REPORT_ONLY_FIRST_FAILURE

    Optional keyword arg ``raise_on_error`` raises an exception on the
    first unexpected exception or failure. This allows failures to be
    post-mortem debugged.

    Optional keyword arg ``parser`` specifies a DocTestParser (or
    subclass) that should be used to extract tests from the files.

    Optional keyword arg ``encoding`` specifies an encoding that should
    be used to convert the file to unicode.

    Advanced tomfoolery:  testmod runs methods of a local instance of
    class doctest.Tester, then merges the results into (or creates)
    global Tester instance doctest.master.  Methods of doctest.master
    can be called directly too, if you want to do something unusual.
    Passing report=0 to testmod is especially useful then, to delay
    displaying a summary.  Invoke doctest.master.summarize(verbose)
    when you're done fiddling.
    z8Package may only be specified for module-relative paths.r)   __main__r   rA   r   )rE  r(  _load_testfilerS   rT   r   copyupdateDebugRunnerSymPyDocTestRunnerSymPyOutputCheckerr?   get_doctestrun	summarizemastermergerN  failurestries)filenamer  namepackageglobsr   r:  rA   
extraglobsraise_on_errorparserr  textrunnerrG   s                  r.   r'  r'    s)   b  + , 	, ,,'?H6ND( |ww) }

Z &j%%g;O#GM,. dE41=D
JJt f%FOOV\\::r-   c                   J    e Zd Z	 	 d	dZ	 	 d
dZd Z	 	 ddZd Zd ZddZ	y)r   Nc                 T   || _         || _        d| _        t               | _        || _        | j
                  j                  | j                         g | _        ||nt        j                         | _	        |rt        |      | _        nd| _        |rt        |      | _        y d| _        y )Nr      
   )_post_mortemr   _countri   	_root_dir	_reporterroot_dirr   r   _seedfloat_fast_threshold_slow_threshold)rE   reporterr   r   r   r   r   s          r.   __init__zSymPyTests.__init__o  s    '&!/!-T6==?
 #(#8D #$D #(#8D #%D r-   c           	         |r| j                   j                          nA|rn>t        j                  | j                         t        j
                  | j                          | j                  j                  | j                         | j                   D ]  }	 | j                  ||||||        | j                  j                         S # t        $ r' t        d       | j                  j                           w xY w)z
        Runs the tests returning True if all tests pass, otherwise False.

        If sort=False run tests in random order.
         interrupted by user)r   r   r   r   rq  shufflero  r,  r9  r   r   finish)rE   r   r   r   r   r   r   s          r.   rG   zSymPyTests.test  s     OO  "KK

#NN4??+TZZ( 	Aq$#_6	 ~~$$&&	 % ,-%%'s   C0C6c                    	
 ddl m}mmmmmm	m
m	m
mm}m} ddddddd	d
ddd
 G 	
fdd|      } ||      } |       j                  |      } ||      S )Nr   )NodeTransformerCompareNameStoreLoadTupleAssignBinOpStrModAssertparsefix_missing_locationsz==z!=<z<=>z>=iszis notinznot in)
EqNotEqLtLtEGtGtEIsIsNotInNotInc                   ,    e Zd Z 	
fdZy).SymPyTests._enhance_asserts.<locals>.Transformc           	         t        |j                        rG|j                  }|j                  g|j                  z   }t	        |      D cg c]
  \  }}d|z   }}}|D cg c]  } |               }}|D cg c]  } |               }	} |              }
 |              } |
g|      } |	d   |j
                  |	dd        }ddj                  |j
                  D cg c]  }|j                  j                      c}      z   dz   }  |               |	                    } |||j                  |j                        }||gS |S c c}}w c c}w c c}w c c}w )Nz_%sr   rP   z
%s z
%s)lineno
col_offset)r   rG   leftcomparatorsrR   opsrU   	__class__r)   r  r  )rE   stmtcomparevaluesr^   _namesnnames_store
names_loadtargetvalueassignnew_compareop
msg_formatr  rG   r  r  r  r}  r  r  r~  r  r  r  r  s                     r.   visit_Assertz;SymPyTests._enhance_asserts.<locals>.Transform.visit_Assert  sc   dii1"iiG%ll^g.A.AAF4=f4EGDAqeaiGEG>C"EDEG$4"EK"E<A!Cq446?!CJ!C";8F!&$&1E#VHe4F")*Q-jQRQSn"UK!(7<<_f_j_j8lY[#bll>S>S:T8l+m!mpv!vJJj$&8QRC!+s4;;SWSbSbcD"D>)K H"E!C
 9ms   E"#E(>E-/ E2
N)r)   r*   r+   r  )r  r  r  r}  r  r  r~  r  r  r  r  s   r.   	Transformr    s       r-   r  )astr|  r}  r~  r  r  r  r  r  r  r  r  r  r  visit)rE   sourcer|  r  r  r  treenew_treer  r  r  r}  r  r  r~  r  r  r  r  s           @@@@@@@@@@@r.   _enhance_assertszSymPyTests._enhance_asserts  sz    	K 	K 	K 	K DD$dXX/	  	  	  	 & V};$$T*$X..r-   c                 .   | j                   }g }	 di}		 fd}
 |
       5 }|j                         }| j                  r_|j                         D ]B  j	                         j                  d      s#t        fd| j                  D              sB n 	 d d d        y d d d        |r	 | j                        }t        ddd      }t        ||	       t%                | xj&                  d	z  c_        t)        j*                  | j,                         |	j/                  d
d      }|swg }|	D ]  }|j                  d      st1        j2                  |	|         st1        j4                  |	|         sF|	|   t7        d      rj8                  t7        d      rt1        j:                        k(  s|j=                  |	|           |r|D cg c]  }t?        |dd      s| }}|jA                  d        d}|tC        |      k  rqt1        jD                  ||         rE|jG                  |      } |       D ])  }|d   |d	d  fd}|jI                  ||       |d	z  }+ n|d	z  }|tC        |      k  rq|D cg c]  }| jK                  |      s| }}|sy 	 |jM                  tC        |             |st)        jN                  |       |D ]  }tQ        jP                         }|jS                  |       	 t?        |dd      r|stU        d      tW               5  |r| jY                  |||       n&t)        j*                  | j,                          |        d d d        |j[                          tQ        jP                         |z
  }|| jr                  kD  rWtt        jv                  jy                  |jz                        |j|                  j=                  dz   |jl                  z   |f       t?        |dd      s/|s3|| j~                  k  sDtt        jv                  jy                  |jz                        |j                  j=                  dz   |jl                  z   |f        |j                          y # 1 sw Y   xY w# t        $ r Y w xY w# t        t        f$ r  t        $ r' |j                  t        j                                Y y t         $ r' |j#                  t        j                                Y :w xY wc c}w c c}w # t         $ r |jM                  tC        |              w xY w# 1 sw Y   xY w# t        $ r$ t?        |dd      r|j]                  d       n Y t         $ r |rt_        j`                  d       t        j                         \  }}}|tb        u r6|je                  |||f       | jf                  rti        jj                  |       n|jl                  dk(  r|j]                  |       nv|jl                  dk(  r|jo                          nV|jl                  dk(  r|jq                  |       n5|j#                  |||f       | jf                  rti        jj                  |       Y w xY w)Nrd   c                      t         d      S )Nr=   )r  )open)r_  s   r.   r   z&SymPyTests.test_file.<locals>.<lambda>  s    DF$C r-   zdef c              3   ~   K   | ]4  }j                         j                  |j                               d k7   6 yw)rO   N)lowerrY   )r   krH  s     r.   r   z'SymPyTests.test_file.<locals>.<genexpr>  s+     &Y1qwwy~~aggi'@B'F&Ys   :=execr   T)flagsdont_inheritrP   disabledFtest___wrapped___slowc                 2    t        j                  |       d   S NrP   )inspectgetsourcelinesr>  s    r.   r   z&SymPyTests.test_file.<locals>.<lambda>  s    )?)?)B1)E r-   keyc                         S r   r,   )argsfuncs   r.   r   z&SymPyTests.test_file.<locals>.<lambda>  s    $+ r-   Slowr   r'   XFailXPassr   )Bro  readr   
splitlineslstrip
startswithr   r  ImportErrorcompiler  
SystemExitr   import_errorrW   exc_info	Exceptiontest_exceptionr	   rm  r   r   rq  r  r  
isfunctionismethodhasattrr  getsourcefilerZ   getattrr   r   isgeneratorfunctionpopinsertmatchesentering_filenamery  timeentering_testr'   r   _timeout	test_pass	test_skipsignalalarmAssertionError	test_failrl  r   r   r)   
test_xfail
test_xpassrt  rS   rT   relpathrn  slow_test_functionsrs  fast_test_functionsleaving_filename)rE   r_  r   r   r   r   r   ru  funcsgl	open_filer   r  coder  r^   fgfgwr>  r,  r   vtrtakenr  r  rH  s    `                      @@@r.   r9  zSymPyTests.test_file  s   >>K	h'B8C	[ #AVVXFxx!'!2!2!4 #A xxz44V<#&&YPTPXPX&Y#Y$)#
 ## # # #!%!6!6v!> vxqtTT2 MKK1KKK

#vvj%0H  	0AW-73E3Ebe3L"++BqE2!!u%dM:#'#3#3D &dM: #006(B!LLA/	0 (-L1GU1KQLEL

E
F#e*n2258< "IIaL"## #B#%a5D#%ab6D"5C!LLC0FA# Q #e*n %*=qT\\!_==  	""8SZ8NN5! .	?AIIKE""1%!%1gu-d!&/)(* a/BDJJ/< ""$IIK%'Et+++77??8X5G5GH,,33_qzz159;q'5)d4///!wwx9K9KLH0077!D1::5u=?[.	?^ 	!!#w# # ' 
  12  %%h? 8''78. M$ >  	&&xU<	  % 1gu-&&':; <  ,LLO<<>1b&&&1bz2((+ZZ9,&&q)ZZ7*'')ZZ7*''*++Q2J7((+#,s   T! R' AR
5R
R
R' !
R' ,R =R' A+T! 0T! 6)T!  T! 9T! T(T,BT! T! TT!T! $U)=U
&U
RR' 	R$ R' #R$$R' '<T#T! %+TT! TT! !&U
U	U)ZDZZc                     fd}t        j                   t         j                  |       t        j                          |        t        j                  d       y )Nc                 d    t        j                  d       rt        dz        t        d      )Nr   zTimed out after %d secondsTimeout)r  r  r1   r'   )r>  yr   r   s     r.   callbackz%SymPyTests._timeout.<locals>.callbackG  s-    LLO"#?'#IJJi((r-   r   )r  SIGALRMr  )rE   r   r   r   r  s     `` r.   r  zSymPyTests._timeoutF  s8    	) 	fnnh/W
Qr-   c                     | j                   sy| j                   D ]>  }|j                  j                         j                  |j                               dk7  s> y y)z
        Does the keyword expression self._kw match "x"? Returns True/False.

        Always returns True if self._kw is "".
        TrO   F)r   r)   r  rY   )rE   r>  r   s      r.   r  zSymPyTests.matchesR  sO     xx(( 	Bzz!&&rxxz2b8	 r-   c           
         t         j                  j                  | j                  t	        |g      d         }g }t        j
                  |      D ]P  \  }}}|j                  |D cg c]/  }t        ||      st         j                  j                  ||      1 c}       R t        |D cg c]!  }t         j                  j                  |      # c}      S c c}w c c}w )z
        Returns the list of test_*.py (default) files at or below directory
        ``dir`` relative to the SymPy home directory.
        r   )
rS   rT   rU   rn  ra   walkr   r   sortedr[   )	rE   dirpatgrT   foldersfilesr   gis	            r.   r   zSymPyTests.get_test_files_  s    
 ggll4>>+BC5+I!+LM$&GGCL 	P D'5HHUNgaobggll4+NO	P a8rww''+899 O8s   %C
7"C
+&C)r  FNNN)FFFFF)TFFFF)z	test_*.py)
r)   r*   r+   rv  rG   r  r9  r  r  r   r,   r-   r.   r   r   m  s?    49@D&2 4938'2/> BG38D$L
:r-   r   c                   8    e Zd Zd Zd Zd ZddZ	 	 	 	 	 ddZy)	r$  c                     d| _         t               | _        || _        | j                  j	                  | j                         || _        g | _        y )Nr   )rm  ri   rn  ro  rp  _normalr   )rE   ru  r  s      r.   rv  zSymPyDocTests.__init__o  s=    &!/r-   c                    | j                   j                          | j                  D ]  }	 | j                  |        | j                   j                         S # t        $ r' t        d       | j                   j                           w xY w)zU
        Runs the tests and returns True if all tests pass, otherwise False.
        rx  )ro  r,  r   r9  r   r   rz  rE   r   s     r.   rG   zSymPyDocTests.testx  sz     	 	Aq!	 ~~$$&&	 % ,-%%'s   A0Bc                 $	   t                ddlm} dd lmc m} ddlm} ddlm	} |t        | j                        dz   d  }t        j                  j                  |      \  }}|j                  t        j                   d      d d }	|j#                  d      r%t$        j                  j'                  d|       |d d }		 t)        j*                  |	      }	t-               j/                  |	      }
	 |j#                  d      rt$        j                  d= 	 |
D cg c]  }t        |j<                        dkD  s| }
}|
j?                  d	 
       |
sy | j6                  jA                  |t        |
             |
D ]	  }t        |j<                        dk7  sJ | j6                  jB                  r4| j6                  jE                  djG                  |jH                               d|jJ                  v r 	  | jL                  di |jJ                  d    tU        | j6                  jB                  dk(  t(        jV                  t(        jX                  z  t(        jZ                  z        }t]               |_/        t$        j`                  }| j6                  jB                  dk(  r|n |       }|t$        _0        | jb                  si |_%        t$        jd                  }tg               \  }}	 |ji                  ||jD                  d      \  }}	 |t$        _0        |dkD  r6| j6                  jk                  |jH                  |jm                                | j6                  jo                          |t$        _2        d|_8         ||       ||_9         | j6                  ju                          y # t0        t2        f$ r  t4        $ rT | j6                  j9                  |t%        j:                                Y |j#                  d      rt$        j                  d= y y w xY w# |j#                  d      rt$        j                  d= w w xY wc c}w # tN        $ r0}| j6                  jQ                  tS        |             Y d }~d }~ww xY w# t2        $ r  w xY w# |t$        _0        w xY w)Nr   )StringIOrl   rn   rP   .r   c                     | j                    S r   )r  r  s    r.   r   z)SymPyDocTests.test_file.<locals>.<lambda>  s    !(( r-   r  z
{} _doctest_depends_on)r     rQ  F)rF   clear_globsr,   );r	   ior  rq   rs   rt   rr   rm   ru   ro   r   rn  rS   rT   rV   replacesepr  rW   r  r(  _normalize_moduleSymPyDocTestFinderrY   r  r   r  ro  r  r  r   r   r  _verbosewriteformatr`  rb  _check_dependenciesr3   r  r   rV  r)  r*  r+  rW  r?   r   r  r&  r|   rY  doctest_failgetvaluer  rv   rw   r  )rE   r_  r  ry   rm   ro   rel_namere   filer   testsrG   erg  oldnewr4  rz   r{   r   r   s                        r.   r9  zSymPyDocTests.test_file  s   AAC4C/!345h/!!"&&#.s3z* HHOOAw'#2YF
	 //7F&(--f5E "":.HHQK"'B$3t}}+=+ABB 	

*
+((3u:> 2	>Dt}}%***~~&&$$W^^DII%>? %

2,D,,Qtzz:O/PQ
 (0G0G0J ( 1 111!244!56F 12FO**C00!3#CCJ <<
 "ooO/;~,n!zz$&)iiU " D1
 !
1u++DIIs||~F((*"116$."#34/=
,e2	>h 	'')Q -. 	 	NN''#,,.A"":.HHQK /		 "":.HHQK / C* ' NN,,s1v,6: %  !
sa   =.N P31P3+P8!Q4AP"P PP %P08	Q1%Q,,Q14Q??RRc           
         d }t         j                  j                  | j                  t	        |g      d         }g }t        j
                  |      D ]`  \  }}}|j                  |D 	cg c]?  }	|	j                  d      s,t        |	|      r t         j                  j                  ||	      A c}	       b |r|D 
cg c]  }
 ||
      s|
 }}
|D cg c]!  }t         j                  j                  |      # c}S c c}	w c c}
w c c}w )a  
        Returns the list of \*.py files (default) from which docstrings
        will be tested which are at or below directory ``dir``. By default,
        only those that have an __init__.py in their parent directory
        and do not start with ``test_`` will be included.
        c                     t         j                  j                  t         j                  j                  |       d      }t         j                  j	                  |      S )aN  
            Checks if given pathname x is an importable module by checking for
            __init__.py file.

            Returns True/False.

            Currently we only test if the __init__.py file exists in the
            directory with the file "x" (in theory we should also test all the
            parent dirs).
            z__init__.py)rS   rT   rU   re   exists)r>  init_pys     r.   
importablez0SymPyDocTests.get_test_files.<locals>.importable  s8     ggll277??1#5}EG77>>'**r-   r   r  )
rS   rT   rU   rn  ra   r  r   r  r   r[   )rE   r  r  r  r/  r	  rT   r
  r  r   r>  r  s               r.   r   zSymPyDocTests.get_test_files  s    	+ ggll4>>+BC5+I!+LM$&GGCL 	I D'5HHU H\\'2wq# ggll4+ H I	I /qA/A//01  $11H 01s   (AC<
;D	D&DNc           	         |D ]%  }t        j                  |      rt        d|z         |D ]F  }|dk(  r&t        ddg didt        f      }|#t        d      t        |      r:t        d	|z         |rt        j                         }	|	d
t        j                  d   t        j                  d<   d}
|D ]  }t        t        j                  j                  |	|      d      5 }|j                  |
       ddd       t        j                  t        j                  j                  |	|      t        j                  t        j                   z  t        j"                  z          |r>t$        j&                  |k  r+t        ddj                  t)        t*        |            z         |t,        |vrt        dt+        |      z         d|v r ddl} G d d      }||j0                  _        yy# 1 sw Y   xY w)z
        Checks if the dependencies for the test are installed.

        Raises ``DependencyError`` it at least one dependency is not installed.
        zCould not find %sr  fromlist)pyplotcmcollectionsz1.0.0)import_kwargsmin_module_versioncatchNzCould not import matplotlibzCould not import %srN   PATHzZ#!/usr/bin/env python3
import sys
if len(sys.argv) <= 1:
    exit("wrong number of args")
wzRequires Python >= r  zRequires ground_types in r  r   c                   *    e Zd Zd Zd Zd Zd Zd Zy)6SymPyDocTests._check_dependencies.<locals>.DummyWindowc                 .    d| _         d| _        d| _        y )NTiX  i  )has_exitwidthheight)rE   r  r   s      r.   rv  z?SymPyDocTests._check_dependencies.<locals>.DummyWindow.__init__@  s    $(DM!$DJ"%DKr-   c                      y r   r,   rE   r>  s     r.   	set_vsyncz@SymPyDocTests._check_dependencies.<locals>.DummyWindow.set_vsyncE      r-   c                      y r   r,   rE   s    r.   	switch_toz@SymPyDocTests._check_dependencies.<locals>.DummyWindow.switch_toH  rC  r-   c                      y r   r,   rA  s     r.   push_handlerszDSymPyDocTests._check_dependencies.<locals>.DummyWindow.push_handlersK  rC  r-   c                      y r   r,   rE  s    r.   closez<SymPyDocTests._check_dependencies.<locals>.DummyWindow.closeN  rC  r-   N)r)   r*   r+   rv  rB  rF  rH  rJ  r,   r-   r.   DummyWindowr;  ?  s    &
r-   rK  )shutilwhichr3   r
   RuntimeErrortempfilemkdtemprS   r   r  rT   rU   r   chmodstatS_IREADS_IWRITES_IXUSRrW   version_inforF  r   r   r  windowWindow)rE   executablesmodulesdisable_viewerspython_versionground_types
executabler   r  tempdirvwviewerfhr  rK  s                  r.   r"  z!SymPyDocTests._check_dependencies  s    & 	HJ<<
+%&9J&FGG	H  	JF%* #-&E#G'.|o	G

 %)*GHH$V,)*?&*HII	J &&(G,3RZZ5G!HBJJv7B
 * F"'',,w7= !HHRL! gv65DFF .0%&;chhs3P^G_>`&`aa#</%&ACDU&UVVw  $ $/FMM - ! !s   &G,,G5	)z*.pyT)r,   r,   r,   )      N)r)   r*   r+   rv  rG   r9  r   r"  r,   r-   r.   r$  r$  m  s0    '\*|2D )+$&,.+1)-L/r-   r$  c                       e Zd ZdZd Zd Zy)r  a;  
    A class used to extract the DocTests that are relevant to a given
    object, from its docstring and the docstrings of its contained
    objects.  Doctests can currently be extracted from the following
    object types: modules, functions, classes, methods, staticmethods,
    classmethods, and properties.

    Modified from doctest's version to look harder for code that
    appears comes from a different module. For example, the @vectorize
    decorator makes it look like functions come from multidimensional.py
    even though their code exists elsewhere.
    c           
         | j                   rt        d|z         t        |      |v ryd|t        |      <   t        j                  |      r"|j
                  j                  d      d   dk7  ry| j                  |||||      }||j                  |       | j                  syt        j                  |      r|j                  j                         D ]  \  }	}
t        j                  |
      st        j                  |
      s1|
j
                  |j                  k7  rK| j                  ||
      sJ |
d|d|	d	       	 |d|	}| j!                  ||
|||||        t%        |d
i       j                         D ]  \  }}
t'        |t(              st+        dt-        |            t        j                  |
      sft        j                  |
      sQt        j.                  |
      s<t        j                  |
      s't'        |
t(              st+        dt-        |
            |d|}| j!                  ||
|||||        t        j                  |      rc|j                  j                         D ]D  \  }}
t'        |
t0              rt%        ||      }
t'        |
t2              rt%        ||      j4                  }
t        j                  t7        |
            s&t        j                  |
      st'        |
t8              s| j                  ||
      st'        |
t8              r:t;        |
j<                  d      r?|
j<                  j
                  |j                  k7  r|
j
                  |j                  k7  r| j                  ||
      sJ |
d|d|d	       |d|}| j!                  ||
|||||       G yy# t"        $ r  w xY w)zo
        Find tests for the given object and any contained objects, and
        add them to ``tests``.
        zFinding tests in %sNrP   r  r   r   z is not in module z
 (rawname )__test__z8SymPyDocTestFinder.find: __test__ keys must be strings: zcSymPyDocTestFinder.find: __test__ values must be strings, functions, methods, classes, or modules: z
.__test__.r*   z
 (valname )r  r   idr  isclassr*   rV   	_get_testrZ   _recurseismodule__dict__itemsr  r)   _from_module_findr   r  r   r   rE  typer  staticmethodclassmethod__func__r   propertyr  fget)rE   r'  objr`  r   source_linesrb  seenrG   rawnamer   valnames               r.   rq  zSymPyDocTestFinder._findb  s]   
 =='$./ c7d?RW ??3~~##C(+w6 ~~c4ELL}} C  # 2 2 4 %%c*gooc.B ~~8 ,,VS9 WADfgVW9-17";

5#w#/>& !(Z < B B D (!'3/$&*7m&6 7 7  **3/7??33G((-1A1A#1F"3,$ '+3i&2 3 3 /3G<

5#w $(($ ??3 # 2 2 4 ,c<0!#w/Cc;/!#w/88C ''s4,"31%%fc2 "#x0"388\:"xx22fooE (>>V__<$,,VS9 2229 *.w7GJJuc7FL$d,9,  - - s   N>>O	c                    d}t        |t              rB|}t        j                  d|      }t	        |      dk(  s
J d|z         t        |d   dd       }n,t        |dd      }|d}t        |t              st        |      }| j                  r|syt        |t              r|j                  j                  y|nt        |      }t        |d	      r&|j                  |j                  d   j                  }	nt        |t              r|j                  }	n|}	| j                  |	|      }|y|d}
n#t        |d
|j                         }
|
dd dv r|
dd }
t        |di       |d<   | j"                  j%                  ||||
|      S )zs
        Return a DocTest for the given object, if it defines a docstring;
        otherwise, return None.
        Nzline \d+rP   z$string '%s' does not contain lineno r   rd  __doc__r  func_closurerd   )z.pycz.pyorO   r  )r   r   r6   findallr   r   r  _exclude_emptyrv  rw  r~  r   r  r  cell_contents_find_linenor)   _parserrX  )rE   rx  r`  r   rb  ry  r  	docstringr  tobjr_  s              r.   rk  zSymPyDocTestFinder._get_test  s     c3 Ijjd3Gw<1$ >6=>$
 AB(F  Y3I 	i-	N	 y c8$xx' >+C sN+0@0@0L''*88C*xx&&t\:F> >Hvz6??CH} 00#CR='.s4I2'N#$||''	5$(0&: 	:r-   N)r)   r*   r+   r~  rq  rk  r,   r-   r.   r  r  T  s    `,DF:r-   r  c                       e Zd ZdZddZy)rV  a  
    A class used to run DocTest test cases, and accumulate statistics.
    The ``run`` method is used to process a single DocTest case.  It
    returns a tuple ``(f, t)``, where ``t`` is the number of test cases
    tried, and ``f`` is the number of test cases that failed.

    Modified from the doctest version to not reset the sys.displayhook (see
    issue 5140).

    See the docstring of the original DocTestRunner for more information.
    Nc                 8   || _         |j                  D ]R  }|j                  j                  dd      |_        |j                  xr |j                  j                  dd      |_        T |t        j                  |j                        }t        j                  }||j                  }| j                  t        _	        t        j                  }t        j                  |      | _        | j                  j!                          | j                  j                  t        _        t
        j"                  j$                  | _        | j(                  t"        _        t+               5  	 | j-                  |||      |t        _	        |t        _        | j&                  t"        _        |r|j                  j/                          cddd       S # |t        _	        |t        _        | j&                  t"        _        |r|j                  j/                          w w xY w# 1 sw Y   yxY w)af  
        Run the examples in ``test``, and display the results using the
        writer function ``out``.

        The examples are run in the namespace ``test.globs``.  If
        ``clear_globs`` is true (the default), then this namespace will
        be cleared after the test runs, to help with garbage
        collection.  If you would like to examine the namespace after
        the test completes, then use ``clear_globs=False``.

        ``compileflags`` gives the set of flags that should be used by
        the Python compiler when running the examples.  If not
        specified, then it will default to the set of future-import
        flags that apply to ``globs``.

        The output of each example is checked using
        ``SymPyDocTestRunner.check_output``, and the results are
        formatted by the ``SymPyDocTestRunner.report_*`` methods.
        z```
r  N)rG   r   wantr  exc_msgr(  _extract_future_flagsrb  rW   r   r   _fakeoutr   	set_trace_OutputRedirectingPdbdebuggerreset	linecachegetlinessave_linecache_getlines/_SymPyDocTestRunner__patched_linecache_getlinesr   _SymPyDocTestRunner__runclear)rE   rG   compileflagsrF   r  rH   save_stdoutsave_set_traces           r.   rY  zSymPyDocTestRunner.run  s   ( 	 }} 	WG"<<//<GL%ooV'//2I2I'SU2VGO	W
 #99$**ELjj;##C]]
  66{C// (0'9'9'B'B$!>>	 !" 	''zz$c:(
 .%)%A%A	"JJ$$&	' 	' )
 .%)%A%A	"JJ$$& 	' 	's&   H G2AHA
HHH)NNT)r)   r*   r+   r~  rY  r,   r-   r.   rV  rV    s    
='r-   rV  )patched_linecache_getlinesrY  record_outcome_DocTestRunner___SymPyDocTestRunner__c                       e Zd ZdZd Zd Zy)rW  z
    Compared to the OutputChecker from the stdlib our OutputChecker class
    supports numerical comparison of floats occurring in the output of the
    doctest examples
    c                     d}|dz   }d}|dz   }d|d|d}d|d	|d|d}t        j                  d
|d|d	      | _        d|d|d}d|d	|d|d}t        j                  d
|d|d	      | _        y )Nz(\d+\.\d*|\.\d+)z(\.{3})?z\s|\+|\-|\*|,z|j|e^z(?=z|$)z(?<=rg  (|)r6   r  num_got_rgxnum_want_rgx)rE   
got_floatswant_floats	front_sepback_sepfbegfmidends          r.   rv  zSymPyOutputChecker.__init__m  s|     )
 !;.$	w&!+X6*3ZJ::4&AB!,h7*3[(KJJD''BCr-   c                 D   ||k(  ry| j                   j                  |      }|D cg c]  }|j                  d       }}| j                  j                  |      }|D cg c]  }|j                  d       }}t	        |      t	        |      k7  ryt	        |      dkD  rg }t        ||      D ]Q  \  }	}
d|
v r|j                  |	       |j                  |
       t        t        |	      t        |
      z
        dkD  sQ y | j                   j                  d|      }|t        |      z  }|t        j                  z  sXt        j                  dt        j                  t        j                        z  d	|      }t        j                  d
d	|      }||k(  ry|t        j                   z  rDdj#                  |j%                               }dj#                  |j%                               }||k(  ry|t        j&                  z  rt        j(                  ||      ryyc c}w c c}w )a  
        Return True iff the actual output from an example (`got`)
        matches the expected output (`want`).  These strings are
        always considered to match if they are identical; but
        depending on what option flags the test runner is using,
        several non-exact match types are also possible.  See the
        documentation for `TestRunner` for more information about
        option flags.
        TrP   Fr   z...gh㈵>%sz(?m)^%s\s*?$r  z
(?m)^\s*?$r5   )r  finditergroupr  r   ziprZ   absrr  r7   tupler(  DONT_ACCEPT_BLANKLINEr6   escapeBLANKLINE_MARKERr*  rU   rV   r)  _ellipsis_match)rE   r  rI   rA   r  rD  numbers_gotnumbers_wantnw_ngnws              r.   check_outputzSymPyOutputChecker.check_output  s    $;
 ""++C03:;%u{{1~;;##,,T24;<5A<<{s<00{aCk<8 !BB;JJrNJJrNuRyr*+d2 ! ""&&uc2Cc
"C h<<<66/BIIh6O6O,PPd$D &&C0Cd{
 666((399;'C88DJJL)Dd{ ***''c2 c <<s   HHN)r)   r*   r+   r~  rv  r  r,   r-   r.   rW  rW  f  s    D(Dr-   rW  c                       e Zd ZdZy)Reporterz)
    Parent class for all reporters.
    N)r)   r*   r+   r~  r,   r-   r.   r  r    s     	r-   r  c                       e Zd ZdZ	 	 ddZd Zed        Z	 	 ddZddZ	d Z
dd	Zd
 Zd Zd Zd Zd Zd Zd Zd ZddZddZd Zd Zy)r   zL
    Py.test like reporter. Should produce output identical to py.test.
    Nc                    || _         || _        || _        || _        d| _        g | _        g | _        g | _        d| _        d| _	        g | _
        d | _        d| _        || _        d| _        d | _        g | _        g | _        d| _        d| _        y )Nr   P   r  F)r  	_tb_style_colors_force_colors_xfailed_xpassed_failed_failed_doctest_passed_skipped_exceptions_terminal_width_default_width_split_active_file	_active_fr  r  
_write_pos
_line_wrap)rE   r   r   r   r   rV   s         r.   rv  zPyTestReporter.__init__  s    )!#  $& #%  r-   c                     || _         y r   )rn  )rE   r  s     r.   rp  zPyTestReporter.root_dir  s	    r-   c                 ^      j                    j                   S  fd} |       }| _         |S )Nc                  |   t         j                  dk(  rddlm} m} | j
                  j                  d      } |d      }| j
                  j                  ||      }|r1dd l}|j                  d|j                        \  }}}}}}}}}}}||z
  S j                  S t        t         j                  d      r*t         j                  j                         sj                  S 	 t        j                   dd	gt        j"                  t        j"                  
      }	|	j%                         \  }
}|
j'                  d      }
d}d}d}|||fD ]A  }t)        j*                  ||
      }||j-                  d      }	 t/        |      }dk7  s?|c S  j                  S # t0        $ r Y "w xY w# t2        $ r Y j                  S w xY w)NrM   r   )windllcreate_string_bufferi   hhhhHhhhhhhisattysttyz-a)r   r   r  zcolumns\s+(?P<columns>\d+);z(?P<columns>\d+)\s*columns;zcolumns\s+=\s+(?P<columns>\d+);columns)rW   rX   ctypesr  r  kernel32GetStdHandleGetConsoleScreenBufferInfostructunpackrawr  r  r   r  r   r   r   r   rC   r6   searchr  r   rE  OSError)r  r  hcsbiresr  r  r  rightprocessr   r   re_linuxre_osx
re_solarisregexrD  r  r>  rE   s                      r.   findout_terminal_widthz=PyTestReporter.terminal_width.<locals>.findout_terminal_width  s   ||w& @OO005+B/oo@@DI!mTXX> =Q1aD!UAq! 4<'...szz8,SZZ5F5F5H***)$**FD>%??%??, ")!4!4!6w/ :7?
&
; )EIIeV4E("'++i"8!$'LE !A:#(L) &&&  * ! !+  2 &&&5s%    AF$ 3F	F! F!$	F;:F;)r  )rE   r  r>  s   `  r.   r.  zPyTestReporter.terminal_width  s8    +'''8	't '($r-   c                 j   d}i }|D ]
  \  }}	|	||<    d}
d}|| j                   }|dk(  rY| j                  t        |      z   |kD  r| j                  d       | j                  d|| j                  z
  t        |      z
  z         | j                  s;t        t        j                  d      r!t        j                  j                         sd	}n$t        j                  d
k(  rd	}n| j                  sd	}| j                  r'|d   dk7  rt        j                  j                  d       t        r"|j                  d      j                  dd      }nt        j                  j                  j!                         j#                  d      sQ|j                  t        j                  j                  d      j                  t        j                  j                        }|d	k(  r t        j                  j                  |       n+t        j                  j                  |||   z  ||
       t        j                  j%                          |j'                  d      }|dk(  r| xj                  t        |      z  c_        nt        |      |z
  dz
  | _        | j                  |k\  | _        | xj                  |z  c_        y)a  
        Prints a text on the screen.

        It uses sys.stdout.write(), so no readline library is necessary.

        Parameters
        ==========

        color : choose from the colors below, "" means default color
        align : "left"/"right", "left" is a normal print, "right" is aligned on
                the right-hand side of the screen, filled with spaces if
                necessary
        width : the screen width

        ))Blackz0;30)Redz0;31)Greenz0;32)Brownz0;33)Bluez0;34)Purplez0;35)Cyanz0;36)	LightGrayz0;37)DarkGrayz1;30)LightRedz1;31)
LightGreenz1;32)Yellowz1;33)	LightBluez1;34)LightPurplez1;35)	LightCyanz1;36)Whitez1;37z[0mz[%smNr  
r5   r  r  rM   r   r<   r=   r>   utfbackslashreplacerO   rP   )r.  r  r   r   r  r  rW   r   r  rX   r  r  
IS_WINDOWSrB   rC   r  r  r  flushrfind)rE   rf  coloralignr>  r   color_templatesr   r`  r  c_normalc_colorrH  s                r.   r   zPyTestReporter.write7  s!   "
& * 	!KD% F4L	!=''EGT*U2

4 JJsEDOO3c$i?@A!!gcjj(&C

!!#
 E\\W$EE??Aw$

  & ;;34;;FHMD$$**,77>;;szz224F   &szz':': ;  B;JJT"JJ6%=($: ;

JJt7OOs4y(O!$i!ma/DO//U25 r-   c                     | j                   }|dk7  rd|z  }|t        |      z
  dz  }||z  |z   |||z
  t        |      z
  z  z   }| j                  |dz          y )Nr  z %s r  r  )r.  r   r   )rE   rf  delimr>  idxr   s         r.   r-  zPyTestReporter.write_center  se    ##2:D=Ds4y Q&#IueckCI&=>>

1t8r-   c                     |j                   }t        j                  |||      }| j                  dj	                  |             y )Nr  )tb_next	tracebackformat_exceptionr   rU   )rE   r(  r   r   r   s        r.   write_exceptionzPyTestReporter.write_exception  s3    ZZ&&q#r2

2771:r-   c           	         | j                  |       t        j                  }t        t        j                        }d|z  }t        j                         }|dk(  r|dt        j                  z  z  }| j                  d|d|d|d       dd	l	m
} | j                  d
|z         ddlm} | j                  d|z         d}	t        dk(  rdd l}
|
j                         }	| j                  dt        d|	d       t!        d      }| j                  d|sd n|j"                  z         || j                  d|z         ddl	m} | j                  d       t'        j(                  d      xs d}|r%|dk(  st+        |      r| j                  d|z         n| j                  d       | j,                  r| j                  d| j,                  z         | j                  d       t/               | _        y )Nz%s.%s.%s-%s-%sPyPyz %s.%s.%s-%s-%szexecutable:         z  (z) [z]
r   )ARCHzarchitecture:       %s
)	USE_CACHEzcache:              %s
r  gmpyzground types:       r5   r  r   znumpy:              %s
zrandom seed:        %d
)HASH_RANDOMIZATIONzhash randomization: r   0r   zon (PYTHONHASHSEED=%s)
zoff
zsplit:              %s
)r-  rW   r^  r  rV  rX   python_implementationpypy_version_infor   sympy.utilities.miscr  sympy.core.cacher  r   gmpy2versionr
   __version__r  rS   r   r   r  clock_t_start)rE   r   r  r^  r  r\  implementationr  r  r   r  r   r  r   s                 r.   r,  zPyTestReporter.start  s   #^^
#""#)A-!779V#/#2G2GGGN

9 	:-

-45.

-	9:&  llnG

L'JKg&

-UHYHYZ[JJ1D89;

)*II./63	9#8C	NJJ1I=>JJw;;JJ1DKK?@

4r-   c                 	    t                _         j                  d       d j                  z  at        t              a fd}t         j                        dkD  r |dt         j                        z         t         j                        dkD  r |dt         j                        z          j                  dkD  r |d j                  z          j                  dkD  r |d j                  z         t         j                        dkD  r |dt         j                        z         t         j                        dkD  r |d	t         j                        z          |d
 j                   j                  z
  z          j                  rD j                  dd       t!         j                  d       }|D ]  \  }}t#        d||fz           j$                  rD j                  dd       t!         j$                  d       }|D ]  \  }}t#        d||fz          t         j                        dkD  rQ j                  dd        j                  D ]  } j                  |d   d|d   d       !  j                  d        j&                  dk7  rt         j                        dkD  r| j                  D ]\  }|\  }}	\  }
}} j                  dd       |	d|z  }n|d|	j(                  } j                  |d        j+                  |
||       ^  j                  d        j&                  dk7  rt         j                        dkD  rr j                  D ]R  }|\  }}	\  }
}} j                  dd        j                  |d|	j(                  d        j+                  |
||       T  j                  d        j&                  dk7  rwt         j                        dkD  r_ j                  D ]?  }|\  }} j                  dd        j                  d|z  d        j                  |       A  j                  d        j                  t               t         j                        dk(  xr2 t         j                        dk(  xr t         j                        dk(  }|s j                  d       |S )Nr  ztests finished: %d passed, c                     	 t         t        |       z   j                  kD  rt        dz  ada t        | z  at         t        |       z  a y )Nr  r   )linelenr   r.  rf  )mytextrE   s    r.   add_textz'PyTestReporter.finish.<locals>.add_text  sB    -V$t':'::FNDs6{"Gr-   r   z%d failed, z%d skipped, z%d expected to fail, z %d expected to fail but passed, z%d exceptions, zin %.2f secondszslowest testsr  c                     | d   S r  r,   r   s    r.   r   z'PyTestReporter.finish.<locals>.<lambda>  s
    1 r-   r  z%s - Took %.3f secondszunexpectedly fast testsc                     | d   S r  r,   r+  s    r.   r   z'PyTestReporter.finish.<locals>.<lambda>  s
    qt r-   zxpassed testsz: rP   nor  r  rN   r   zDO *NOT* COMMIT!
)r"  _t_endr   r  rf  r   r'  r  r  r  r  r  r  r#  r  r-  r  r   r  r  r)   r  )rE   r)  sorted_slowslow_func_namer  sorted_fastfast_func_namer(  r_  r   r   r   r   r8   r  oks   `               r.   rz  zPyTestReporter.finish  sG   g

4,t||;d)	# t||q ]S%667t##$q(]S)=)=%>>?==1^dmm34==1,t}}<=t}}!7#dmm:LLMt 1$&T-=-=)>>?"dkkDMM&ABC##os3 !9!9~NK)4 J%..%1HHIJ ##7= !9!9%35K)4 J%..%1HHIJ t}}!os3]] 6

1qt456JJt>>T!c$*:*:&;a&?%% 1,-)!\ab!!"c*9xA#+QZZ8A!!!S)$$QR01 JJt>>T!c$,,&7!&;\\ 1,-)!\ab!!"c*!!h

"CSI$$QR0	1
 JJt>>T!c$*>*>&?!&C))   !#!!"c*!!$/37

3	 
 JJt$!# +D,<,<(=(B +$$%* 	JJ+,	r-   c                     |t        | j                        dz   d  }|| _        d| _        | j	                  |       | j	                  d|z         y )NrP   Fz[%d] )r   rn  r  _active_file_errorr   )rE   r_  r  r%  s       r.   r  z PyTestReporter.entering_filename	  sI    C/!345$"'

8

7Q;r-   c                     | j                  d       | j                  r| j                  ddd       n| j                  ddd       | j                  d       | j                  r| j                  d       y y )	Nr5   [FAIL]r  r  r  z[OK]r  r  )r   r5  r  rE  s    r.   r  zPyTestReporter.leaving_filename	  s^    

3""JJxgJ6JJvwgJ6

4==JJt r-   c                 n    || _         | j                  r"| j                  d|j                  z   dz          y y )Nr  r5   )r  r  r   r)   r  s     r.   r  zPyTestReporter.entering_test'	  s/    ==JJtajj(3./ r-   c                 R    | xj                   dz  c_         | j                  dd       y )NrP   r   r  )r  r   rE  s    r.   r  zPyTestReporter.test_xfail,	  s    

3 r-   c                     t        |      }| j                  j                  | j                  |f       | j	                  dd       y )NXr  )r   r  rZ   r  r   )rE   r  messages      r.   r  zPyTestReporter.test_xpass0	  s6    a&d//9:

3 r-   c                     | j                   j                  | j                  | j                  |f       | j	                  dd       d| _        y )NFr  T)r  rZ   r  r  r   r5  rE   r  s     r.   r  zPyTestReporter.test_fail5	  s;    T..IJ

3"&r-   c                     dj                  |j                  d      dd        }| j                  j                  ||f       | j	                  dd       d| _        y )Nr  rP   r?  r  T)rU   rV   r  rZ   r   r5  )rE   r`  	error_msgs      r.   r#  zPyTestReporter.doctest_fail:	  sO    IIiood3AB78	##T9$56

3"&r-   c                     | xj                   dz  c_         | j                  r| j                  dd       y | j                  |d       y )NrP   r3  r  )r  r  r   )rE   chars     r.   r  zPyTestReporter.test_passA	  s3    ==JJtW%JJtW%r-   c                 
   d}| xj                   dz  c_         |"t        |      }|dk(  rd}n|dk(  rd}n|dk(  rd}| j                  r*|| j                  d	z   d
       n| j                  dd
       | j                  |d
       y )Nr8   rP   r   Kr  Tr  r9  r5   r  z - )r  r   r  r   )rE   r  rD  r=  s       r.   r  zPyTestReporter.test_skipH	  s    =!fG--I%F"==}

7S=&1

5&)

4 r-   c                     | j                   j                  | j                  | j                  |f       |d   t        u r| j                  dd       d| _        y | j                  dd       d| _        y )Nr   rG  r  ET)r  rZ   r  r  r1   r   r5  r@  s     r.   r  zPyTestReporter.test_exceptionZ	  sc    !2!2DNNH MNA;,&JJsE" #' JJsE""&r-   c                 (   | j                   j                  |d |f       |t        | j                        dz   d  }| j	                  |       | j	                  dd       | j	                  d       | j	                  ddd       | j	                  d       y )	NrP   z[?]   Failed to importr  r5   r7  r  r8  r  )r  rZ   r   rn  r   )rE   r_  r  r%  s       r.   r  zPyTestReporter.import_errorb	  s|    4 :;C/!345

8

+U3

3

8U'
2

4r-   )Fr   TFN)r  r  NF)=)Nztest process starts)r  r   )r)   r*   r+   r~  rv  rp  rv  r.  r   r-  r  r,  rz  r  r  r  r  r  r  r#  r  r  r  r  r,   r-   r.   r   r     s     :>+/ 8 A AF 9= X!t! FRh 0
!!
'
'&!$'r-   r   )   )T)r,   Nr,   Nr,   Nr   )Pr~  rS   rW   rX   r  r  r   r6   r  r  r   timeitr   r"  r   r(  r   r   r   r   rL  r  rR  rO  r   
contextlibr   r   r  r	   r  r
   sympy.external.gmpyr   r`  r  r   r   r   r   r  r'   r1   r3   r:   rJ   report_failurera   ri   r|   r   r^  r   r   rG   r   r  r   r  rC  r   r4  rM  rN  DocTestParserr'  r   r$  r  rV  monkeypatched_methodsmethodoldnamenewnamesetattrr  OutputCheckerrW  r  r   r,   r-   r.   <module>rX     su   
 
    
 	    )  0        %  ( ( ,ggo
		$*** S 	i 		9 		i 	/  
1 #2M &',. 
 
 !#cnn'uYx -126487t ! dP 'ddD%E5RDJKZ  $1 GT|~]~ RZZ)*7?r #02DE ,0tTdU*H**,ty;x}: }:@d/ d/Nv: v:rJ' J'\ 
 $ JF 6)G%.G)HIJ_// _D	 	ZX Zr-   