def test_has_extension(): binalyzer = Binalyzer() 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"))
def test_add_extension_at_object_creation(): binalyzer = Binalyzer() 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")) assert id(mock) == id(binalyzer.mock)
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)
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