def mocked_file(monkeypatch): monkeypatch.setattr(BoxFile, 'set_box_item', MagicMock()) bf = BoxFile(None, None) bf._box_item = MagicMock() return bf