Describe the bug
test_louvain_communities_empty_graph and test_pagerank_empty_graph integration tests fail because prior test methods in the same module sync data to Neptune via the neptune_graph fixture (module-scoped, autouse), and that data is never cleaned up between individual test methods. The empty graph tests create a local empty graph and pass it to the algorithm with backend='neptune', but the Neptune instance still contains nodes and edges from earlier tests.
To Reproduce
- Set
NETWORKX_GRAPH_ID to a running Neptune Analytics graph
- Run
python -m pytest integ_test/test_algo_louvain.py -v --tb=short
- Observe
test_louvain_communities_empty_graph fails with assert 2 == 0 (gets 2 communities from leftover data)
- Run
python -m pytest integ_test/test_algo_page_rank.py -v --tb=short
- Observe
test_pagerank_empty_graph fails with assert 6 == 0 (gets 6 node scores from leftover data)
Expected behavior
Both empty graph tests should return empty results:
test_louvain_communities_empty_graph: len(result) == 0
test_pagerank_empty_graph: len(r) == 0
Screenshots
FAILED integ_test/test_algo_louvain.py::TestLouvain::test_louvain_communities_empty_graph
AssertionError: assert 2 == 0
where 2 = len([{'A', 'B', 'C'}, {'D', 'E', 'F'}])
FAILED integ_test/test_algo_page_rank.py::TestPageRank::test_pagerank_empty_graph
AssertionError: assert 6 == 0
where 6 = len({'A': 0.0291, 'B': 0.0538, 'C': 0.3152, 'D': 0.2962, ...})
Desktop (please complete the following information):
- OS: macOS
- Version: nx-neptune 0.5.0
Additional context
Root cause: neptune_graph fixture is scope='module' and autouse=True. Earlier test methods use test_graph/test_digraph fixtures that sync nodes (A-F) and edges to Neptune. No cleanup happens between test methods. The empty graph tests run last by source order and inherit the Neptune state.
Suggested fix: add a clear_graph() call before the empty/single-node tests, either via a fixture or at the start of the test method.
Affected tests:
integ_test/test_algo_louvain.py::TestLouvain::test_louvain_communities_empty_graph
integ_test/test_algo_page_rank.py::TestPageRank::test_pagerank_empty_graph
Describe the bug
test_louvain_communities_empty_graphandtest_pagerank_empty_graphintegration tests fail because prior test methods in the same module sync data to Neptune via theneptune_graphfixture (module-scoped, autouse), and that data is never cleaned up between individual test methods. The empty graph tests create a local empty graph and pass it to the algorithm withbackend='neptune', but the Neptune instance still contains nodes and edges from earlier tests.To Reproduce
NETWORKX_GRAPH_IDto a running Neptune Analytics graphpython -m pytest integ_test/test_algo_louvain.py -v --tb=shorttest_louvain_communities_empty_graphfails withassert 2 == 0(gets 2 communities from leftover data)python -m pytest integ_test/test_algo_page_rank.py -v --tb=shorttest_pagerank_empty_graphfails withassert 6 == 0(gets 6 node scores from leftover data)Expected behavior
Both empty graph tests should return empty results:
test_louvain_communities_empty_graph:len(result) == 0test_pagerank_empty_graph:len(r) == 0Screenshots
FAILED integ_test/test_algo_louvain.py::TestLouvain::test_louvain_communities_empty_graph
AssertionError: assert 2 == 0
where 2 = len([{'A', 'B', 'C'}, {'D', 'E', 'F'}])
FAILED integ_test/test_algo_page_rank.py::TestPageRank::test_pagerank_empty_graph
AssertionError: assert 6 == 0
where 6 = len({'A': 0.0291, 'B': 0.0538, 'C': 0.3152, 'D': 0.2962, ...})
Desktop (please complete the following information):
Additional context
Root cause:
neptune_graphfixture isscope='module'andautouse=True. Earlier test methods usetest_graph/test_digraphfixtures that sync nodes (A-F) and edges to Neptune. No cleanup happens between test methods. The empty graph tests run last by source order and inherit the Neptune state.Suggested fix: add a
clear_graph()call before the empty/single-node tests, either via a fixture or at the start of the test method.Affected tests:
integ_test/test_algo_louvain.py::TestLouvain::test_louvain_communities_empty_graphinteg_test/test_algo_page_rank.py::TestPageRank::test_pagerank_empty_graph