a
    h                     @   s0  d Z ddlZddlZddlZddlmZ ddlZddlZdd Zdd Z	dd	 Z
ejd
ddd Zejd
ddd ZzddlZd
ZW n ey   dZY n0 zddlZd
ZW n ey   dZY n0 zddlZd
ZW n ey   dZY n0 zddlZd
ZW n ey   dZY n0 zddlZd
ZW n eyB   dZY n0 zddlZd
ZW n eyl   dZY n0 zddlZd
ZW n ey   dZY n0 g Zg dZg dZdgZ dgZ!dgZ"dgZ#dgZ$esee7 Zesee7 Zesee 7 Zesee!7 Zesee"7 Zesee#7 Zes,ee$7 ZdS )ax  
Testing
=======

General guidelines for writing good tests:

- doctests always assume ``import networkx as nx`` so don't add that
- prefer pytest fixtures over classes with setup methods.
- use the ``@pytest.mark.parametrize``  decorator
- use ``pytest.importorskip`` for numpy, scipy, pandas, and matplotlib b/c of PyPy.
  and add the module to the relevant entries below.

    N)entry_pointsc                 C   s:   | j ddddd | j ddd dd | j d	ddd
d d S )N	--runslow
store_trueFzrun slow tests)actiondefaulthelp	--backendstorezGRun tests with a backend by auto-converting nx graphs to backend graphs--fallback-to-nxz[Run nx function if a backend doesn't implement a dispatchable function (use with --backend))Z	addoption)parser r   ?/var/www/auris/lib/python3.9/site-packages/networkx/conftest.pypytest_addoption   s    r   c                 C   s   |  dd | d}|d u r*tjd}|rf|gtjjj_	| d}|sVtjd}t
|tjjj_tjdk rdd	 t d
 D }ntdd
d}|rtt|tjjjd< n
td d S )Nmarkerszslow: mark test as slow to runr   ZNETWORKX_TEST_BACKENDr
   ZNETWORKX_FALLBACK_TO_NX)   
   c                 s   s   | ]}|j d kr|V  qdS )nx-loopbackN)name).0epr   r   r   	<genexpr>8   s   z#pytest_configure.<locals>.<genexpr>znetworkx.backendsr   )r   groupac  

             WARNING: Mixed NetworkX configuration! 

        This environment has mixed configuration for networkx.
        The test object nx-loopback is not configured correctly.
        You should not be seeing this message.
        Try `pip install -e .`, or change your PYTHONPATH
        Make sure python finds the networkx repo you are testing

)Zaddinivalue_line	getoptionosenvirongetnetworkxutilsbackends	_dispatch_automatic_backendsboolZ_fallback_to_nxsysversion_infor   nextiterwarningswarn)configbackendZfallback_to_nxr   r   r   r   pytest_configure+   s(    


r*   c                 C   s   dt jjj_t jjjj }rJt jjj|d   }t|drJt|d| | 	drXd S t
jjdd}|D ]}d|jv rj|| qjd S )NTr   Zon_start_testsr   zneed --runslow option to run)reasonZslow)r   r   r   r   Z_is_testingr    loadhasattrgetattrr   pytestmarkskipkeywordsZ
add_marker)r(   itemsZautomatic_backendsr)   Z	skip_slowitemr   r   r   pytest_collection_modifyitemsJ   s    


r5   T)Zautousec                   C   s   t jdtdd t jdtdd t jdtdd t jdtdd t jdtdd t jdtdd t jdtd	d t jdtd
d t jdtdd t jdtdd d S )Nignoreznx.nx_pydot)categorymessagez'single_target_shortest_path_length willzshortest_path for all_pairsz
forest_str is deprecatedz

random_treezEdmonds has been deprecatedz(MultiDiGraph_EdgeKey has been deprecatedz

The `normalized`zfunction `join` is deprecatedz)

strongly_connected_components_recursive)r&   filterwarningsDeprecationWarningr   r   r   r   set_warnings_   sL    r;   c                 C   s8   t | d< zdd l}|jdd W n ty2   Y n0 d S )NZnxr   z1.21)legacy)r   numpyZset_printoptionsImportError)Zdoctest_namespacenpr   r   r   add_nx   s    r@   F)	.algorithms/approximation/traveling_salesman.pyz/algorithms/centrality/current_flow_closeness.py!algorithms/node_classification.pyzalgorithms/non_randomness.pyz"algorithms/shortest_paths/dense.pylinalg/bethehessianmatrix.pyzlinalg/laplacianmatrix.pyzutils/misc.py"algorithms/centrality/laplacian.py)rA   z'algorithms/assortativity/correlation.pyz"algorithms/assortativity/mixing.pyz!algorithms/assortativity/pairs.pyzalgorithms/bipartite/matrix.pyz algorithms/bipartite/spectral.pyz1algorithms/centrality/current_flow_betweenness.pyz8algorithms/centrality/current_flow_betweenness_subset.pyz$algorithms/centrality/eigenvector.pyzalgorithms/centrality/katz.pyz%algorithms/centrality/second_order.pyz%algorithms/centrality/subgraph_alg.pyz!algorithms/communicability_alg.pyz$algorithms/link_analysis/hits_alg.pyz(algorithms/link_analysis/pagerank_alg.pyrB   zalgorithms/similarity.pyconvert_matrix.pyzdrawing/layout.pyz"generators/spectral_graph_forge.pyzlinalg/algebraicconnectivity.pyzlinalg/attrmatrix.pyrC   zlinalg/graphmatrix.pyzlinalg/modularitymatrix.pyzlinalg/spectrum.pyzutils/rcm.pyrD   zdrawing/nx_pylab.pyrE   zdrawing/nx_agraph.pyzdrawing/nx_pydot.pyzalgorithms/polynomials.py)%__doc__r   r"   r&   importlib.metadatar   r/   r   r   r*   r5   Zfixturer;   r@   r=   Z	has_numpyr>   ZscipyZ	has_scipyZ
matplotlibZhas_matplotlibZpandasZ
has_pandasZ
pygraphvizZhas_pygraphvizZpydotZ	has_pydotZsympyZ	has_sympyZcollect_ignoreZneeds_numpyZneeds_scipyZneeds_matplotlibZneeds_pandasZneeds_pygraphvizZneeds_pydotZneeds_sympyr   r   r   r   <module>   s   

)








