Skip to content

Commit 9611c53

Browse files
authored
Merge pull request #10 from hiratara/fix-unicode-tests
test: disable idfa when using UTF-8
2 parents 7d7222f + 2da0820 commit 9611c53

1 file changed

Lines changed: 54 additions & 27 deletions

File tree

tests_mozilla.py

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -235,31 +235,40 @@ def test_get_tld_US_K129(self):
235235
assert 'k12.ak.us' == publicsuffix.get_tld('www.test.k12.ak.us')
236236

237237
def test_get_tld_IDN_labels1(self):
238-
assert 'com.cn' == publicsuffix.get_tld('食狮.com.cn')
238+
psl = publicsuffix.PublicSuffixList(idna=False)
239+
assert 'com.cn' == psl.get_tld('食狮.com.cn')
239240

240241
def test_get_tld_IDN_labels2(self):
241-
assert 'cn' == publicsuffix.get_tld('食狮.公司.cn')
242+
psl = publicsuffix.PublicSuffixList(idna=False)
243+
assert '公司.cn' == psl.get_tld('食狮.公司.cn')
242244

243245
def test_get_tld_IDN_labels3(self):
244-
assert 'cn' == publicsuffix.get_tld('www.食狮.公司.cn')
246+
psl = publicsuffix.PublicSuffixList(idna=False)
247+
assert '公司.cn' == psl.get_tld('www.食狮.公司.cn')
245248

246249
def test_get_tld_IDN_labels4(self):
247-
assert 'cn' == publicsuffix.get_tld('shishi.公司.cn')
250+
psl = publicsuffix.PublicSuffixList(idna=False)
251+
assert '公司.cn' == psl.get_tld('shishi.公司.cn')
248252

249253
def test_get_tld_IDN_labels5(self):
250-
assert 'cn' == publicsuffix.get_tld('公司.cn')
254+
psl = publicsuffix.PublicSuffixList(idna=False)
255+
assert '公司.cn' == psl.get_tld('公司.cn')
251256

252257
def test_get_tld_IDN_labels6(self):
253-
assert '中国' == publicsuffix.get_tld('食狮.中国')
258+
psl = publicsuffix.PublicSuffixList(idna=False)
259+
assert '中国' == psl.get_tld('食狮.中国')
254260

255261
def test_get_tld_IDN_labels7(self):
256-
assert '中国' == publicsuffix.get_tld('www.食狮.中国')
262+
psl = publicsuffix.PublicSuffixList(idna=False)
263+
assert '中国' == psl.get_tld('www.食狮.中国')
257264

258265
def test_get_tld_IDN_labels8(self):
259-
assert '中国' == publicsuffix.get_tld('shishi.中国')
266+
psl = publicsuffix.PublicSuffixList(idna=False)
267+
assert '中国' == psl.get_tld('shishi.中国')
260268

261269
def test_get_tld_IDN_labels9(self):
262-
assert '中国' == publicsuffix.get_tld('中国')
270+
psl = publicsuffix.PublicSuffixList(idna=False)
271+
assert '中国' == psl.get_tld('中国')
263272

264273
def test_get_tld_Same_as_above_but_punycoded1(self):
265274
assert 'com.cn' == publicsuffix.get_tld('xn--85x722f.com.cn')
@@ -490,31 +499,40 @@ def test_get_tld_US_K129(self):
490499
assert 'k12.ak.us' == publicsuffix.get_tld('www.test.k12.ak.us', strict=True)
491500

492501
def test_get_tld_IDN_labels1(self):
493-
assert 'com.cn' == publicsuffix.get_tld('食狮.com.cn', strict=True)
502+
psl = publicsuffix.PublicSuffixList(idna=False)
503+
assert 'com.cn' == psl.get_tld('食狮.com.cn', strict=True)
494504

495505
def test_get_tld_IDN_labels2(self):
496-
assert 'cn' == publicsuffix.get_tld('食狮.公司.cn', strict=True)
506+
psl = publicsuffix.PublicSuffixList(idna=False)
507+
assert '公司.cn' == psl.get_tld('食狮.公司.cn', strict=True)
497508

498509
def test_get_tld_IDN_labels3(self):
499-
assert 'cn' == publicsuffix.get_tld('www.食狮.公司.cn', strict=True)
510+
psl = publicsuffix.PublicSuffixList(idna=False)
511+
assert '公司.cn' == psl.get_tld('www.食狮.公司.cn', strict=True)
500512

501513
def test_get_tld_IDN_labels4(self):
502-
assert 'cn' == publicsuffix.get_tld('shishi.公司.cn', strict=True)
514+
psl = publicsuffix.PublicSuffixList(idna=False)
515+
assert '公司.cn' == psl.get_tld('shishi.公司.cn', strict=True)
503516

504517
def test_get_tld_IDN_labels5(self):
505-
assert 'cn' == publicsuffix.get_tld('公司.cn', strict=True)
518+
psl = publicsuffix.PublicSuffixList(idna=False)
519+
assert '公司.cn' == psl.get_tld('公司.cn', strict=True)
506520

507521
def test_get_tld_IDN_labels6(self):
508-
assert None == publicsuffix.get_tld('食狮.中国', strict=True)
522+
psl = publicsuffix.PublicSuffixList(idna=False)
523+
assert '中国' == psl.get_tld('食狮.中国', strict=True)
509524

510525
def test_get_tld_IDN_labels7(self):
511-
assert None == publicsuffix.get_tld('www.食狮.中国', strict=True)
526+
psl = publicsuffix.PublicSuffixList(idna=False)
527+
assert '中国' == psl.get_tld('www.食狮.中国', strict=True)
512528

513529
def test_get_tld_IDN_labels8(self):
514-
assert None == publicsuffix.get_tld('shishi.中国', strict=True)
530+
psl = publicsuffix.PublicSuffixList(idna=False)
531+
assert '中国' == psl.get_tld('shishi.中国', strict=True)
515532

516533
def test_get_tld_IDN_labels9(self):
517-
assert None == publicsuffix.get_tld('中国', strict=True)
534+
psl = publicsuffix.PublicSuffixList(idna=False)
535+
assert '中国' == psl.get_tld('中国', strict=True)
518536

519537
def test_get_tld_Same_as_above_but_punycoded1(self):
520538
assert 'com.cn' == publicsuffix.get_tld('xn--85x722f.com.cn', strict=True)
@@ -745,31 +763,40 @@ def test_get_sld_US_K129(self):
745763
assert 'test.k12.ak.us' == publicsuffix.get_sld('www.test.k12.ak.us')
746764

747765
def test_get_sld_IDN_labels1(self):
748-
assert '食狮.com.cn' == publicsuffix.get_sld('食狮.com.cn')
766+
psl = publicsuffix.PublicSuffixList(idna=False)
767+
assert '食狮.com.cn' == psl.get_sld('食狮.com.cn')
749768

750769
def test_get_sld_IDN_labels2(self):
751-
assert '公司.cn' == publicsuffix.get_sld('食狮.公司.cn')
770+
psl = publicsuffix.PublicSuffixList(idna=False)
771+
assert '食狮.公司.cn' == psl.get_sld('食狮.公司.cn')
752772

753773
def test_get_sld_IDN_labels3(self):
754-
assert '公司.cn' == publicsuffix.get_sld('www.食狮.公司.cn')
774+
psl = publicsuffix.PublicSuffixList(idna=False)
775+
assert '食狮.公司.cn' == psl.get_sld('www.食狮.公司.cn')
755776

756777
def test_get_sld_IDN_labels4(self):
757-
assert '公司.cn' == publicsuffix.get_sld('shishi.公司.cn')
778+
psl = publicsuffix.PublicSuffixList(idna=False)
779+
assert 'shishi.公司.cn' == psl.get_sld('shishi.公司.cn')
758780

759781
def test_get_sld_IDN_labels5(self):
760-
assert '公司.cn' == publicsuffix.get_sld('公司.cn')
782+
psl = publicsuffix.PublicSuffixList(idna=False)
783+
assert '公司.cn' == psl.get_sld('公司.cn')
761784

762785
def test_get_sld_IDN_labels6(self):
763-
assert '中国' == publicsuffix.get_sld('食狮.中国')
786+
psl = publicsuffix.PublicSuffixList(idna=False)
787+
assert '食狮.中国' == psl.get_sld('食狮.中国')
764788

765789
def test_get_sld_IDN_labels7(self):
766-
assert '中国' == publicsuffix.get_sld('www.食狮.中国')
790+
psl = publicsuffix.PublicSuffixList(idna=False)
791+
assert '食狮.中国' == psl.get_sld('www.食狮.中国')
767792

768793
def test_get_sld_IDN_labels8(self):
769-
assert '中国' == publicsuffix.get_sld('shishi.中国')
794+
psl = publicsuffix.PublicSuffixList(idna=False)
795+
assert 'shishi.中国' == psl.get_sld('shishi.中国')
770796

771797
def test_get_sld_IDN_labels9(self):
772-
assert '中国' == publicsuffix.get_sld('中国')
798+
psl = publicsuffix.PublicSuffixList(idna=False)
799+
assert '中国' == psl.get_sld('中国')
773800

774801
def test_get_sld_Same_as_above_but_punycoded1(self):
775802
assert 'xn--85x722f.com.cn' == publicsuffix.get_sld('xn--85x722f.com.cn')

0 commit comments

Comments
 (0)