()
| 90 | |
| 91 | |
| 92 | def test_options(): |
| 93 | o = TO() |
| 94 | assert o.keys() == {"bool", "one", "two", "required_int"} |
| 95 | |
| 96 | assert o.one is None |
| 97 | assert o.two == 2 |
| 98 | o.one = 1 |
| 99 | assert o.one == 1 |
| 100 | |
| 101 | with pytest.raises(TypeError): |
| 102 | TO(nonexistent="value") |
| 103 | with pytest.raises(Exception, match="Unknown options"): |
| 104 | o.nonexistent = "value" |
| 105 | with pytest.raises(Exception, match="Unknown options"): |
| 106 | o.update(nonexistent="value") |
| 107 | assert o.update_known(nonexistent="value") == {"nonexistent": "value"} |
| 108 | |
| 109 | rec = [] |
| 110 | |
| 111 | def sub(updated): |
| 112 | rec.append(copy.copy(o)) |
| 113 | |
| 114 | o.changed.connect(sub) |
| 115 | |
| 116 | o.one = 90 |
| 117 | assert len(rec) == 1 |
| 118 | assert rec[-1].one == 90 |
| 119 | |
| 120 | o.update(one=3) |
| 121 | assert len(rec) == 2 |
| 122 | assert rec[-1].one == 3 |
| 123 | |
| 124 | |
| 125 | def test_setter(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…