jitenbot/tests/test_sankoku_phrases.py

48 lines
2.1 KiB
Python
Raw Normal View History

2023-07-18 05:43:38 +00:00
import unittest
from bot.entries.sankoku8 import parse_hyouki_pattern
from bs4 import BeautifulSoup
class TestSankokuPhrases(unittest.TestCase):
def test_sankoku_phrases1(self):
pattern = '耳にたこ(ができる)'
exps = parse_hyouki_pattern(pattern)
self.assertEqual(len(exps), 2)
self.assertIn("耳にたこ", exps)
self.assertIn("耳にたこができる", exps)
def test_sankoku_phrases2(self):
pattern = '一斑を〈見て/もって〉全豹を〈卜す/推す〉'
exps = parse_hyouki_pattern(pattern)
self.assertEqual(len(exps), 4)
self.assertIn("一斑を見て全豹を卜す", exps)
self.assertIn("一斑を見て全豹を推す", exps)
self.assertIn("一斑をもって全豹を卜す", exps)
self.assertIn("一斑をもって全豹を推す", exps)
def test_sankoku_phrases3(self):
pattern = '{かじ・舵}を切る'
exps = parse_hyouki_pattern(pattern)
self.assertEqual(len(exps), 2)
self.assertIn("かじを切る", exps)
self.assertIn("舵を切る", exps)
def test_sankoku_phrases4(self):
pattern = '重箱の隅を(⦅ようじ\楊枝⦆で)〈つつく/ほじくる〉'
exps = parse_hyouki_pattern(pattern)
self.assertEqual(len(exps), 6)
self.assertIn("重箱の隅をつつく", exps)
self.assertIn("重箱の隅をようじでつつく", exps)
self.assertIn("重箱の隅を楊枝でつつく", exps)
self.assertIn("重箱の隅をほじくる", exps)
self.assertIn("重箱の隅をようじでほじくる", exps)
self.assertIn("重箱の隅を楊枝でほじくる", exps)
def test_sankoku_phrases5(self):
pattern = '群盲象を〈{な・撫}でる/評する〉'
exps = parse_hyouki_pattern(pattern)
self.assertEqual(len(exps), 3)
self.assertIn("群盲象をなでる", exps)
self.assertIn("群盲象を撫でる", exps)
self.assertIn("群盲象を評する", exps)