コード例 #1
0
 def test_from_body(self):
     mappings = [
         (b"\x03\x02\xdf\xdd\x23", Response),
         (b"Some plain text\ndata with tabs\t and null bytes\0", TextResponse),
         (b"<html><head><title>Hello</title></head>", HtmlResponse),
         (b'<?xml version="1.0" encoding="utf-8"', XmlResponse),
     ]
     for source, cls in mappings:
         retcls = responsetypes.from_body(source)
         assert retcls is cls, "%s ==> %s != %s" % (source, retcls, cls)
コード例 #2
0
 def test_from_body(self):
     mappings = [
         ('\x03\x02\xdf\xdd\x23', Response),
         ('Some plain text\ndata with tabs\t and null bytes\0', TextResponse),
         ('<html><head><title>Hello</title></head>', HtmlResponse),
         ('<?xml version="1.0" encoding="utf-8"', XmlResponse),
     ]
     for source, cls in mappings:
         retcls = responsetypes.from_body(source)
         assert retcls is cls, "%s ==> %s != %s" % (source, retcls, cls)
コード例 #3
0
ファイル: test_responsetypes.py プロジェクト: runt18/scrapy
 def test_from_body(self):
     mappings = [
         (b'\x03\x02\xdf\xdd\x23', Response),
         (b'Some plain text\ndata with tabs\t and null bytes\0', TextResponse),
         (b'<html><head><title>Hello</title></head>', HtmlResponse),
         (b'<?xml version="1.0" encoding="utf-8"', XmlResponse),
     ]
     for source, cls in mappings:
         retcls = responsetypes.from_body(source)
         assert retcls is cls, "{0!s} ==> {1!s} != {2!s}".format(source, retcls, cls)
コード例 #4
0
 def test_from_body(self):
     mappings = [
         (b'\x03\x02\xdf\xdd\x23', Response),
         (b'Some plain text\ndata with tabs\t and null bytes\0', TextResponse),
         (b'<html><head><title>Hello</title></head>', HtmlResponse),
         # https://codersblock.com/blog/the-smallest-valid-html5-page/
         (b'<!DOCTYPE html>\n<title>.</title>', HtmlResponse),
         (b'<?xml version="1.0" encoding="utf-8"', XmlResponse),
     ]
     for source, cls in mappings:
         retcls = responsetypes.from_body(source)
         assert retcls is cls, f"{source} ==> {retcls} != {cls}"