MCPcopy
hub / github.com/psf/black / test_decode_with_encoding

Method test_decode_with_encoding

tests/test_black.py:2132–2157  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2130 assert black.format_str("".join(test_case), mode=mode) == test_case[0] * 3
2131
2132 def test_decode_with_encoding(self) -> None:
2133 # This uses temporary files since some editors (including GitHub)
2134 # struggle with displaying and/or editing non utf-8 data
2135 # \xfc is iso-8859-1 for ü
2136 with NamedTemporaryFile(delete=False) as first_line:
2137 first_line.write(
2138 b"# -*- coding: iso-8859-1 -*-\n"
2139 b"# 2002-11-22 J\xfcrgen Hermann <jh@web.de>\n"
2140 )
2141 first_line.close()
2142 self.assertFalse(
2143 ff(Path(first_line.name)),
2144 "Failed to properly detect encoding",
2145 )
2146
2147 with NamedTemporaryFile(delete=False) as second_line:
2148 second_line.write(
2149 b"#! /usr/bin/env python3\n"
2150 b"# -*- coding: iso-8859-1 -*-\n"
2151 b"# 2002-11-22 J\xfcrgen Hermann <jh@web.de>\n"
2152 )
2153 second_line.close()
2154 self.assertFalse(
2155 ff(Path(second_line.name)),
2156 "Failed to properly detect encoding on second line",
2157 )
2158
2159
2160class TestCaching:

Callers

nothing calls this directly

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected