fix: 仅对储存历史CSV使用GBK
This commit is contained in:
@@ -40,9 +40,8 @@ class PipelineTest(unittest.TestCase):
|
||||
self.assertEqual(len(converted), 7)
|
||||
summary_path = result / f"interference_summary_{TARGET_KEY}.csv"
|
||||
summary_bytes = summary_path.read_bytes()
|
||||
self.assertFalse(summary_bytes.startswith(b"\xef\xbb\xbf"))
|
||||
self.assertIn("小区".encode("gbk"), summary_bytes)
|
||||
with summary_path.open(encoding="gbk", newline="") as file:
|
||||
self.assertTrue(summary_bytes.startswith(b"\xef\xbb\xbf"))
|
||||
with summary_path.open(encoding="utf-8-sig", newline="") as file:
|
||||
rows = list(csv.DictReader(file))
|
||||
self.assertEqual(len(rows), 7)
|
||||
self.assertEqual(
|
||||
@@ -246,8 +245,12 @@ class PipelineTest(unittest.TestCase):
|
||||
self.assertEqual(rows[1]["prev_interference_dbm"], "")
|
||||
self.assertEqual(rows[1]["prev_nearby_count"], "")
|
||||
|
||||
def test_gbk_csv_normalizes_non_breaking_spaces(self) -> None:
|
||||
payload = main.dict_csv_bytes(("cell_name",), [{"cell_name": "测试\u00a0小区"}])
|
||||
def test_gbk_history_csv_normalizes_non_breaking_spaces(self) -> None:
|
||||
payload = main.dict_csv_bytes(
|
||||
("cell_name",),
|
||||
[{"cell_name": "测试\u00a0小区"}],
|
||||
main.HISTORY_CSV_ENCODING,
|
||||
)
|
||||
|
||||
self.assertEqual(payload.decode("gbk"), "cell_name\r\n测试 小区\r\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user