Пример #1
0
class MyTestCase(unittest.TestCase):
    async def setUpAsync(self):
        self.qh = QuestionHandler()

    def setUp(self) -> None:
        self.loop = asyncio.get_event_loop()
        self.loop.run_until_complete(self.setUpAsync())

    def tearDown(self) -> None:
        self.loop.run_until_complete(self.qh.close())

    def test_find_keywords_consecutive_capitals(self):
        self.assertEqual(
            self.qh.find_keywords("Do you love Nathaniel Hawthorne's books?"),
            ["love", "Nathaniel Hawthorne's", "books"],
        )

    def test_find_keywords_quotations(self):
        self.assertEqual(
            self.qh.find_keywords('I do love "The Scarlet Letter".'),
            ["love", "The Scarlet Letter"],
        )

    def test_answer_question(self):
        self.loop.run_until_complete(
            self.qh.answer_question(
                "What is the word for a landmass like Florida that is "
                "surrounded on three sides by water?",
                ["Peninsula", "Piñata", "Trifecta"],
            ))
async def test():
    qh = QuestionHandler()
    # await qh.answer_question("Which of these shows just announced three new cast members?",
    #                          ["Saturday Night Live", "M*A*S*H", "Supernatural"])
    await qh.answer_question(
        "In the 19th century, where were spats typically worn?",
        ["Ears", "Arms", "Feet"])
    await qh.close()
async def test():
    qh = QuestionHandler()
    # fails because all pages say foot/footwear instead of feet
    # await qh.answer_question('In the 19th century, where were spats typically worn?',
    #                          ['Ears', 'Arms', 'Feet'])

    # await qh.answer_question('Which of these games is played on a court?',
    #                          ['Basketball', 'Super Mario Kart', 'Uno'])

    # for is removed as a stopword
    await qh.answer_question("What do NEITHER of the N's in CNN stand for?",
                             ['News', 'Netflix', 'Network'])
    await qh.close()
Пример #4
0
 async def setUpAsync(self):
     self.qh = QuestionHandler()
Пример #5
0
 async def __aenter__(self):
     self.question_handler = QuestionHandler()
     return self