示例#1
0
 def test_options_from_headerline(self, headerline, section_name, section_options):
     try:
         SectionMarker.from_headerline(
             f"<<<{headerline}>>>".encode("ascii")
         ) == (  # type: ignore[comparison-overlap]
             section_name,
             section_options,
         )
     except ValueError:
         assert section_name is None
示例#2
0
 def test_options_serialize_options(self):
     section_header = SectionMarker.from_headerline(b"<<<" + b":".join((
         b"section",
         b"cached(1,2)",
         b"encoding(ascii)",
         b"nostrip()",
         b"persist(42)",
         b"sep(124)",
     )) + b">>>")
     assert section_header == SectionMarker.from_headerline(
         str(section_header).encode("ascii"))
示例#3
0
 def test_options_decode_defaults(self):
     section_header = SectionMarker.from_headerline(b"<<<name>>>")
     assert section_header.name == SectionName("name")
     assert section_header.cached is None
     assert section_header.encoding == "utf-8"
     assert section_header.nostrip is False
     assert section_header.persist is None
     assert section_header.separator is None
示例#4
0
 def test_options_decode_values(self):
     section_header = SectionMarker.from_headerline(b"<<<" + b":".join((
         b"name",
         b"cached(1,2)",
         b"encoding(ascii)",
         b"nostrip()",
         b"persist(42)",
         b"sep(124)",
     )) + b">>>")
     assert section_header.name == SectionName("name")
     assert section_header.cached == (1, 2)
     assert section_header.encoding == "ascii"
     assert section_header.nostrip is True
     assert section_header.persist == 42
     assert section_header.separator == "|"
示例#5
0
 def test_options_deserialize_defaults(self):
     section_header = SectionMarker.from_headerline(b"<<<section>>>")
     other_header = SectionMarker.from_headerline(str(section_header).encode("ascii"))
     assert section_header == other_header
     assert str(section_header) == str(other_header)