HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux host 6.8.0-107-generic #107-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 13 19:51:50 UTC 2026 x86_64
User: w230 (1248)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/networkx/algorithms/tests/test_node_classification_deprecations.py
"""TODO: Remove this test module for version 3.0."""


import sys

import pytest

# NOTE: It is necessary to prevent previous imports in the test suite from
# "contaminating" the tests for the deprecation warnings by removing
# node_classification from sys.modules.


def test_hmn_deprecation_warning():
    sys.modules.pop("networkx.algorithms.node_classification", None)
    with pytest.warns(DeprecationWarning):
        from networkx.algorithms.node_classification import hmn


def test_lgc_deprecation_warning():
    sys.modules.pop("networkx.algorithms.node_classification", None)
    with pytest.warns(DeprecationWarning):
        from networkx.algorithms.node_classification import lgc


def test_no_warn_on_function_import(recwarn):
    # Accessing the functions shouldn't raise any warning
    sys.modules.pop("networkx.algorithms.node_classification", None)
    from networkx.algorithms.node_classification import (
        harmonic_function,
        local_and_global_consistency,
    )

    assert len(recwarn) == 0


def test_no_warn_on_package_import(recwarn):
    # Accessing the package shouldn't raise any warning
    sys.modules.pop("networkx.algorithms.node_classification", None)
    from networkx.algorithms import node_classification

    assert len(recwarn) == 0