(self)
| 426 | del p5.blog |
| 427 | |
| 428 | def test_history(self): |
| 429 | for base in (object, MyBaseClass, MyClass): |
| 430 | |
| 431 | class Foo(base): |
| 432 | pass |
| 433 | |
| 434 | class Bar(base): |
| 435 | pass |
| 436 | |
| 437 | register_class(Foo) |
| 438 | register_class(Bar) |
| 439 | _register_attribute(Foo, "name", uselist=False, useobject=False) |
| 440 | _register_attribute( |
| 441 | Foo, "bars", uselist=True, trackparent=True, useobject=True |
| 442 | ) |
| 443 | _register_attribute(Bar, "name", uselist=False, useobject=False) |
| 444 | |
| 445 | f1 = Foo() |
| 446 | f1.name = "f1" |
| 447 | |
| 448 | eq_( |
| 449 | attributes.get_state_history( |
| 450 | attributes.instance_state(f1), "name" |
| 451 | ), |
| 452 | (["f1"], (), ()), |
| 453 | ) |
| 454 | |
| 455 | b1 = Bar() |
| 456 | b1.name = "b1" |
| 457 | f1.bars.append(b1) |
| 458 | eq_( |
| 459 | attributes.get_state_history( |
| 460 | attributes.instance_state(f1), "bars" |
| 461 | ), |
| 462 | ([b1], [], []), |
| 463 | ) |
| 464 | |
| 465 | attributes.instance_state(f1)._commit_all( |
| 466 | attributes.instance_dict(f1) |
| 467 | ) |
| 468 | attributes.instance_state(b1)._commit_all( |
| 469 | attributes.instance_dict(b1) |
| 470 | ) |
| 471 | |
| 472 | eq_( |
| 473 | attributes.get_state_history( |
| 474 | attributes.instance_state(f1), "name" |
| 475 | ), |
| 476 | ((), ["f1"], ()), |
| 477 | ) |
| 478 | eq_( |
| 479 | attributes.get_state_history( |
| 480 | attributes.instance_state(f1), "bars" |
| 481 | ), |
| 482 | ((), [b1], ()), |
| 483 | ) |
| 484 | |
| 485 | f1.name = "f1mod" |
nothing calls this directly
no test coverage detected