This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/networkx/utils/tests/test_contextmanager.py

21 lines
312 B
Python
Raw Normal View History

2020-07-30 01:16:18 +02:00
import networkx as nx
def test_reversed():
G = nx.DiGraph()
G.add_edge('A', 'B')
# no exception
with nx.utils.reversed(G):
pass
assert 'B' in G['A']
# exception
try:
with nx.utils.reversed(G):
raise Exception
except:
assert 'B' in G['A']