def testKeywordPhraseExtraction(self): expected_phrases = ['MOCK'] with tempfile.TemporaryFile() as f: # We can't use mock_open here, because it doesn't seem to work # with the 'for line in f' syntax f.write("MOCK\n") f.seek(0) with mock.patch('%s.open' % vocabcompiler.__name__, return_value=f, create=True): extracted_phrases = vocabcompiler.get_keyword_phrases() self.assertEqual(expected_phrases, extracted_phrases)
def get_passive_instance(cls): phrases = vocabcompiler.get_keyword_phrases() return cls.get_instance('keyword', phrases)