| 28 | |
| 29 | @pytest.mark.parametrize("cfg", [EmptyConfig(), Config()]) |
| 30 | def 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 | |
| 53 | def test_config_subclass(): |