示例#1
0
def test_add_extension():
    mock = MockExtension(None)
    binalyzer = Binalyzer()
    binalyzer.extensions = {}
    binalyzer.add_extension("mock", mock)
    assert binalyzer.has_extension("mock")
    assert len(binalyzer.extensions) == 1
    assert isinstance(binalyzer.extensions["mock"], MockExtension)
    assert id(mock) == id(binalyzer.extension("mock"))
    assert id(mock) == id(binalyzer.mock)
示例#2
0
def test_dispose_extension():
    binalyzer = Binalyzer()
    binalyzer.extensions = {}
    mock = MockExtension(binalyzer)
    assert binalyzer.has_extension("mock")
    assert len(binalyzer.extensions) == 1
    assert isinstance(binalyzer.extensions["mock"], MockExtension)
    assert id(mock) == id(binalyzer.extension("mock"))
    binalyzer.del_extension("mock")
    assert not binalyzer.has_extension("mock")
    assert len(binalyzer.extensions) == 0
    assert mock.disposed