(self)
| 251 | assert target.settings.get_comment("host") == {"eol": "bind address"} |
| 252 | |
| 253 | def test_box_list_index_changes(self): |
| 254 | bl = BoxList(["a", "b", "c", "d"]) |
| 255 | for index in range(4): |
| 256 | bl.set_comment(index, "abcd"[index]) |
| 257 | |
| 258 | def comments(): |
| 259 | return [(bl.get_comment(i) or {}).get("eol") for i in range(len(bl))] |
| 260 | |
| 261 | bl.insert(1, "new") |
| 262 | assert comments() == ["a", None, "b", "c", "d"] |
| 263 | bl.pop(1) |
| 264 | assert comments() == ["a", "b", "c", "d"] |
| 265 | del bl[0] |
| 266 | assert comments() == ["b", "c", "d"] |
| 267 | bl.remove("c") |
| 268 | assert comments() == ["b", "d"] |
| 269 | bl.insert(-1, "x") |
| 270 | assert bl == ["b", "x", "d"] and comments() == ["b", None, "d"] |
| 271 | bl.reverse() |
| 272 | assert comments() == ["d", None, "b"] |
| 273 | bl.sort() |
| 274 | assert bl == ["b", "d", "x"] and comments() == ["b", "d", None] |
| 275 | bl.sort(key=lambda v: v == "b", reverse=True) |
| 276 | assert bl == ["b", "d", "x"] and comments() == ["b", "d", None] |
| 277 | bl.append("e") |
| 278 | bl += ["f"] |
| 279 | assert comments() == ["b", "d", None, None, None] |
| 280 | bl.pop() |
| 281 | bl[0:2] = ["y"] # slice writes drop the list's item comments |
| 282 | assert comments() == [None, None, None] |
| 283 | bl.set_comment(0, "again") |
| 284 | bl.clear() |
| 285 | bl.append(1) |
| 286 | assert bl.get_comment(0) is None |
| 287 | |
| 288 | def test_box_list_copies_and_pickles(self): |
| 289 | bl = BoxList.from_yaml("- 1 # one\n- 2\n") |
nothing calls this directly
no test coverage detected