def test_import_handler_imports_content_with_respect_to_regex(self, monkeypatch): handlerInput = "import fakepath.py (\t*this$)" def FileHelperMock(*args): return "\t\tthat\n\t\tthis not\n\t\tthis" def extractMock(content, regex): if content not in "\t\tthat\n\t\tthis not\n\t\tthis" \ or regex not in "(\t*this$)": raise AssertionError return "\t\tthis" monkeypatch.setattr(helper, 'load', FileHelperMock) monkeypatch.setattr(helper, 'extract', extractMock) x = Import() x.handle(handlerInput) assert x.output(wrapper=None) == "\t\tthis"