Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit28f1400

Browse files
committed
Get test_stream.py working again after the inputstream changes from ages ago
1 parentdf1e5de commit28f1400

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

‎html5lib/tests/test_stream.py‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
from .importsupport
22
importunittest,codecs
33

4-
fromhtml5lib.inputstreamimportHTMLInputStream
4+
fromhtml5lib.inputstreamimportHTMLInputStream,HTMLUnicodeInputStream,HTMLBinaryInputStream
55

6-
classHTMLInputStreamShortChunk(HTMLInputStream):
6+
classHTMLUnicodeInputStreamShortChunk(HTMLUnicodeInputStream):
7+
_defaultChunkSize=2
8+
9+
classHTMLBinaryInputStreamShortChunk(HTMLBinaryInputStream):
710
_defaultChunkSize=2
811

912
classHTMLInputStreamTest(unittest.TestCase):
1013

1114
deftest_char_ascii(self):
12-
stream=HTMLInputStream("'",encoding='ascii')
15+
stream=HTMLInputStream(b"'",encoding='ascii')
1316
self.assertEquals(stream.charEncoding[0],'ascii')
1417
self.assertEquals(stream.char(),"'")
1518

16-
deftest_char_null(self):
17-
stream=HTMLInputStream("\x00")
18-
self.assertEquals(stream.char(),'\ufffd')
19-
2019
deftest_char_utf8(self):
2120
stream=HTMLInputStream('\u2018'.encode('utf-8'),encoding='utf-8')
2221
self.assertEquals(stream.charEncoding[0],'utf-8')
@@ -30,7 +29,7 @@ def test_char_win1252(self):
3029
self.assertEquals(stream.char(),"\u2019")
3130

3231
deftest_bom(self):
33-
stream=HTMLInputStream(codecs.BOM_UTF8+"'")
32+
stream=HTMLInputStream(codecs.BOM_UTF8+b"'")
3433
self.assertEquals(stream.charEncoding[0],'utf-8')
3534
self.assertEquals(stream.char(),"'")
3635

@@ -40,7 +39,7 @@ def test_utf_16(self):
4039
self.assertEquals(len(stream.charsUntil(' ',True)),1025)
4140

4241
deftest_newlines(self):
43-
stream=HTMLInputStreamShortChunk(codecs.BOM_UTF8+"a\nbb\r\nccc\rddddxe")
42+
stream=HTMLBinaryInputStreamShortChunk(codecs.BOM_UTF8+b"a\nbb\r\nccc\rddddxe")
4443
self.assertEquals(stream.position(), (1,0))
4544
self.assertEquals(stream.charsUntil('c'),"a\nbb\n")
4645
self.assertEquals(stream.position(), (3,0))
@@ -50,12 +49,12 @@ def test_newlines(self):
5049
self.assertEquals(stream.position(), (4,5))
5150

5251
deftest_newlines2(self):
53-
size=HTMLInputStream._defaultChunkSize
52+
size=HTMLUnicodeInputStream._defaultChunkSize
5453
stream=HTMLInputStream("\r"*size+"\n")
5554
self.assertEquals(stream.charsUntil('x'),"\n"*size)
5655

5756
deftest_position(self):
58-
stream=HTMLInputStreamShortChunk(codecs.BOM_UTF8+"a\nbb\nccc\nddde\nf\ngh")
57+
stream=HTMLBinaryInputStreamShortChunk(codecs.BOM_UTF8+b"a\nbb\nccc\nddde\nf\ngh")
5958
self.assertEquals(stream.position(), (1,0))
6059
self.assertEquals(stream.charsUntil('c'),"a\nbb\n")
6160
self.assertEquals(stream.position(), (3,0))
@@ -73,7 +72,7 @@ def test_position(self):
7372
self.assertEquals(stream.position(), (6,1))
7473

7574
deftest_position2(self):
76-
stream=HTMLInputStreamShortChunk("abc\nd")
75+
stream=HTMLUnicodeInputStreamShortChunk("abc\nd")
7776
self.assertEquals(stream.position(), (1,0))
7877
self.assertEquals(stream.char(),"a")
7978
self.assertEquals(stream.position(), (1,1))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp