Skip to content

Commit

Permalink
Merge pull request #24 from i3thuan5/照sonarcloud整理
Browse files Browse the repository at this point in the history
照sonarcloud整理
  • Loading branch information
a8568730 authored Jan 19, 2024
2 parents 5424299 + d2db348 commit 8770fd3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
39 changes: 20 additions & 19 deletions test/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@


class TanGuanTshiGiam(TestCase):
parser = 'html.parser'

def test_ok(self):
kiatko = tuitse_html([
('好', 'hó', THAU_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
soup.ruby.rb.string, 'hó'
)
Expand All @@ -21,7 +22,7 @@ def test_nng_su(self):
('真', 'tsin', THAU_JI, True),
('好', 'hó', THAU_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
len(soup.find_all('rb')), 2
)
Expand All @@ -31,7 +32,7 @@ def test_siangji_e_lomaji(self):
('姑', 'koo', THAU_JI, True),
('娘', 'niû', LIAN_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
len(soup.find_all('rb')), 3
)
Expand All @@ -45,7 +46,7 @@ def test_khinsiann_hu(self):
('轉', 'tńg', THAU_JI, True),
('去', 'khì', KHIN_SIANN_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
len(soup.find_all('rb')), 3
)
Expand All @@ -55,7 +56,7 @@ def test_tsuanlo_su(self):
('koo', 'koo', THAU_JI, True),
('niu', 'niu', LIAN_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(soup.find_all('rt')[2].text, 'niu', kiatko)
self.assertEqual(soup.find_all('rb')[2].text, 'niu', kiatko)
self.assertEqual(soup.find_all('rt')[1].text, '-', kiatko)
Expand All @@ -66,7 +67,7 @@ def test_khinsiann_e_tsuanlo_su(self):
('tńg', 'tńg', THAU_JI, True),
('khì', 'khì', KHIN_SIANN_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
len(soup.find_all('ruby')), 1
)
Expand All @@ -77,7 +78,7 @@ def test_hanlo_su_e_hanji(self):
('kòng', 'kòng', LIAN_JI, True),
('kòng', 'kòng', LIAN_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
len(soup.find_all('ruby')), 1
)
Expand All @@ -88,7 +89,7 @@ def test_hanlo_su_e_lomaji(self):
('kòng', 'kòng', LIAN_JI, True),
('kòng', 'kòng', LIAN_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
len(soup.find_all('ruby')), 1
)
Expand All @@ -99,7 +100,7 @@ def test_kinnkinn叫_e_hanji(self):
('kinn', 'kinn', LIAN_JI, True),
('叫', '叫', THAU_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
len(soup.find_all('ruby')), 2
)
Expand All @@ -110,7 +111,7 @@ def test_kinnkinn叫_e_lomaji(self):
('kinn', 'kinn', LIAN_JI, True),
('叫', '叫', LIAN_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
len(soup.find_all('ruby')), 1
)
Expand All @@ -120,7 +121,7 @@ def test_tsuanhan_su(self):
('帥', '帥', THAU_JI, True),
('哥', '哥', LIAN_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(
len(soup.find_all('ruby')), 1
)
Expand All @@ -131,7 +132,7 @@ def test_khinsiann(self):
('起', 'khí', KHIN_SIANN_JI, True),
('來', 'lâi', LIAN_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(soup.find_all('rt')[2].text, '起', kiatko)
self.assertEqual(soup.find_all('rb')[2].text, 'khí', kiatko)
self.assertEqual(soup.find_all('rt')[1].text, '', kiatko)
Expand All @@ -145,22 +146,22 @@ def test_khiam_hanji(self):
kiatko = tuitse_html([
('', 'hó', THAU_JI, False),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(soup.find_all('rt')[0]['class'], ['fail'])

def test_khiam_lomaji(self):
kiatko = tuitse_html([
('好', '', THAU_JI, False),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(soup.find_all('rb')[0]['class'], ['fail'])

def test_khiam_bue(self):
kiatko = tuitse_html([
('姑', 'koo', THAU_JI, True),
('娘', '', LIAN_JI, False),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertNotIn('class', soup.find_all('rb')[0])
self.assertEqual(soup.find_all('rb')[2]['class'], ['fail'])

Expand All @@ -171,7 +172,7 @@ def test_khiam_tiongng(self):
('喜', 'hí', LIAN_JI, True),
('喜', '', THAU_JI, True),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
lomaji = ''
for rb in soup.ruby.find_all('rb'):
lomaji += re.sub(r'\s', ' ', rb.text)
Expand All @@ -181,7 +182,7 @@ def test_bo_tuitang(self):
kiatko = tuitse_html([
('好', 'bái', THAU_JI, False),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertEqual(soup.find_all('rb')[0]['class'], ['fail'])

def test_tiongng_bo_tuitang(self):
Expand All @@ -190,7 +191,7 @@ def test_tiongng_bo_tuitang(self):
('轉', 'ng', KHIN_SIANN_JI, False),
('去', 'i', LIAN_JI, False),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
self.assertNotIn('class', soup.find_all('rb')[0])
self.assertEqual(soup.find_all('rb')[2]['class'], ['fail'])
self.assertEqual(soup.find_all('rb')[4]['class'], ['fail'])
Expand All @@ -200,6 +201,6 @@ def test_lianjihu_mai_laklohlai(self):
('tánn', '', THAU_JI, False),
('pān', '', LIAN_JI, False),
])
soup = BeautifulSoup(kiatko, "html.parser")
soup = BeautifulSoup(kiatko, self.parser)
khangpeh = soup.find_all('rb')[1].text
self.assertEqual(len(khangpeh), 1)
1 change: 0 additions & 1 deletion test/test_widget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# from unittest.case import TestCase
import json
from unittest.mock import Mock

Expand Down
2 changes: 1 addition & 1 deletion test_django_proj/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SECRET_KEY = 'h4vw(tfyf!u1x$3l02j522x_a5dlsl%x0(sxqyw=zv*eu3e0^x'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False

ALLOWED_HOSTS = []

Expand Down
3 changes: 1 addition & 2 deletions tuitse/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ def tuitse_boolean(kiamtsa_tinliat):
for tsua in kiamtsa_tinliat:
if not tsua[-1]:
return False
else:
return True
return True

0 comments on commit 8770fd3

Please sign in to comment.