Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/networkx/conftest.py @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 import pytest | |
2 import networkx | |
3 import sys | |
4 import warnings | |
5 | |
6 | |
7 def pytest_addoption(parser): | |
8 parser.addoption( | |
9 "--runslow", action="store_true", default=False, help="run slow tests" | |
10 ) | |
11 | |
12 | |
13 def pytest_configure(config): | |
14 config.addinivalue_line("markers", "slow: mark test as slow to run") | |
15 | |
16 | |
17 def pytest_collection_modifyitems(config, items): | |
18 if config.getoption("--runslow"): | |
19 # --runslow given in cli: do not skip slow tests | |
20 return | |
21 skip_slow = pytest.mark.skip(reason="need --runslow option to run") | |
22 for item in items: | |
23 if "slow" in item.keywords: | |
24 item.add_marker(skip_slow) | |
25 | |
26 | |
27 # TODO: The warnings below need to be dealt with, but for now we silence them. | |
28 @pytest.fixture(autouse=True) | |
29 def set_warnings(): | |
30 warnings.filterwarnings( | |
31 "ignore", | |
32 category=DeprecationWarning, | |
33 message="literal_stringizer is deprecated*", | |
34 ) | |
35 warnings.filterwarnings( | |
36 "ignore", | |
37 category=DeprecationWarning, | |
38 message="literal_destringizer is deprecated*", | |
39 ) | |
40 warnings.filterwarnings( | |
41 "ignore", category=DeprecationWarning, message="is_string_like is deprecated*" | |
42 ) | |
43 warnings.filterwarnings( | |
44 "ignore", category=DeprecationWarning, message="make_str is deprecated*" | |
45 ) | |
46 warnings.filterwarnings( | |
47 "ignore", | |
48 category=DeprecationWarning, | |
49 message="context manager reversed is deprecated*", | |
50 ) | |
51 warnings.filterwarnings( | |
52 "ignore", | |
53 category=DeprecationWarning, | |
54 message="This will return a generator in 3.0*", | |
55 ) | |
56 warnings.filterwarnings( | |
57 "ignore", category=DeprecationWarning, message="betweenness_centrality_source*", | |
58 ) | |
59 warnings.filterwarnings( | |
60 "ignore", category=DeprecationWarning, message="edge_betweeness*", | |
61 ) | |
62 warnings.filterwarnings( | |
63 "ignore", | |
64 category=PendingDeprecationWarning, | |
65 message="the matrix subclass is not the recommended way*", | |
66 ) | |
67 | |
68 | |
69 @pytest.fixture(autouse=True) | |
70 def add_nx(doctest_namespace): | |
71 doctest_namespace["nx"] = networkx | |
72 | |
73 | |
74 # What dependencies are installed? | |
75 | |
76 try: | |
77 import numpy | |
78 | |
79 has_numpy = True | |
80 except ImportError: | |
81 has_numpy = False | |
82 | |
83 try: | |
84 import scipy | |
85 | |
86 has_scipy = True | |
87 except ImportError: | |
88 has_scipy = False | |
89 | |
90 try: | |
91 import matplotlib | |
92 | |
93 has_matplotlib = True | |
94 except ImportError: | |
95 has_matplotlib = False | |
96 | |
97 try: | |
98 import pandas | |
99 | |
100 has_pandas = True | |
101 except ImportError: | |
102 has_pandas = False | |
103 | |
104 try: | |
105 import pygraphviz | |
106 | |
107 has_pygraphviz = True | |
108 except ImportError: | |
109 has_pygraphviz = False | |
110 | |
111 try: | |
112 import yaml | |
113 | |
114 has_yaml = True | |
115 except ImportError: | |
116 has_yaml = False | |
117 | |
118 try: | |
119 import pydot | |
120 | |
121 has_pydot = True | |
122 except ImportError: | |
123 has_pydot = False | |
124 | |
125 try: | |
126 import ogr | |
127 | |
128 has_ogr = True | |
129 except ImportError: | |
130 has_ogr = False | |
131 | |
132 | |
133 # List of files that pytest should ignore | |
134 | |
135 collect_ignore = [] | |
136 | |
137 needs_numpy = [ | |
138 "algorithms/centrality/current_flow_closeness.py", | |
139 "algorithms/node_classification/__init__.py", | |
140 "algorithms/non_randomness.py", | |
141 "algorithms/shortest_paths/dense.py", | |
142 "linalg/bethehessianmatrix.py", | |
143 "linalg/laplacianmatrix.py", | |
144 "utils/misc.py", | |
145 ] | |
146 needs_scipy = [ | |
147 "algorithms/assortativity/correlation.py", | |
148 "algorithms/assortativity/mixing.py", | |
149 "algorithms/assortativity/pairs.py", | |
150 "algorithms/bipartite/matrix.py", | |
151 "algorithms/bipartite/spectral.py", | |
152 "algorithms/centrality/current_flow_betweenness.py", | |
153 "algorithms/centrality/current_flow_betweenness_subset.py", | |
154 "algorithms/centrality/eigenvector.py", | |
155 "algorithms/centrality/katz.py", | |
156 "algorithms/centrality/second_order.py", | |
157 "algorithms/centrality/subgraph_alg.py", | |
158 "algorithms/communicability_alg.py", | |
159 "algorithms/link_analysis/hits_alg.py", | |
160 "algorithms/link_analysis/pagerank_alg.py", | |
161 "algorithms/node_classification/hmn.py", | |
162 "algorithms/node_classification/lgc.py", | |
163 "algorithms/similarity.py", | |
164 "convert_matrix.py", | |
165 "drawing/layout.py", | |
166 "generators/spectral_graph_forge.py", | |
167 "linalg/algebraicconnectivity.py", | |
168 "linalg/attrmatrix.py", | |
169 "linalg/graphmatrix.py", | |
170 "linalg/modularitymatrix.py", | |
171 "linalg/spectrum.py", | |
172 "utils/rcm.py", | |
173 ] | |
174 needs_matplotlib = ["drawing/nx_pylab.py"] | |
175 needs_pandas = ["convert_matrix.py"] | |
176 needs_yaml = ["readwrite/nx_yaml.py"] | |
177 needs_pygraphviz = ["drawing/nx_agraph.py"] | |
178 needs_pydot = ["drawing/nx_pydot.py"] | |
179 needs_ogr = ["readwrite/nx_shp.py"] | |
180 | |
181 if not has_numpy: | |
182 collect_ignore += needs_numpy | |
183 if not has_scipy: | |
184 collect_ignore += needs_scipy | |
185 if not has_matplotlib: | |
186 collect_ignore += needs_matplotlib | |
187 if not has_pandas: | |
188 collect_ignore += needs_pandas | |
189 if not has_yaml: | |
190 collect_ignore += needs_yaml | |
191 if not has_pygraphviz: | |
192 collect_ignore += needs_pygraphviz | |
193 if not has_pydot: | |
194 collect_ignore += needs_pydot | |
195 if not has_ogr: | |
196 collect_ignore += needs_ogr | |
197 | |
198 # FIXME: This is to avoid errors on AppVeyor | |
199 if sys.platform.startswith("win"): | |
200 collect_ignore += ["readwrite/graph6.py", "readwrite/sparse6.py"] |