MCPcopy
hub / github.com/networkx/networkx / test_config_empty

Function test_config_empty

networkx/utils/tests/test_config.py:30–50  ·  view source on GitHub ↗
(cfg)

Source from the content-addressed store, hash-verified

28
29@pytest.mark.parametrize("cfg", [EmptyConfig(), Config()])
30def test_config_empty(cfg):
31 assert dir(cfg) == []
32 with pytest.raises(AttributeError):
33 cfg.x = 1
34 with pytest.raises(KeyError):
35 cfg["x"] = 1
36 with pytest.raises(AttributeError):
37 cfg.x
38 with pytest.raises(KeyError):
39 cfg["x"]
40 assert len(cfg) == 0
41 assert "x" not in cfg
42 assert cfg == cfg
43 assert cfg.get("x", 2) == 2
44 assert set(cfg.keys()) == set()
45 assert set(cfg.values()) == set()
46 assert set(cfg.items()) == set()
47 cfg2 = pickle.loads(pickle.dumps(cfg))
48 assert cfg == cfg2
49 assert isinstance(cfg, collections.abc.Collection)
50 assert isinstance(cfg, collections.abc.Mapping)
51
52
53def test_config_subclass():

Callers

nothing calls this directly

Calls 4

keysMethod · 0.80
valuesMethod · 0.80
getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…