MCPcopy Index your code
hub / github.com/python/cpython / test_dialect_apply

Method test_dialect_apply

Lib/test/test_csv.py:648–676  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

646 self.assertEqual(fileobj.read(), expected)
647
648 def test_dialect_apply(self):
649 class testA(csv.excel):
650 delimiter = "\t"
651 class testB(csv.excel):
652 delimiter = ":"
653 class testC(csv.excel):
654 delimiter = "|"
655 class testUni(csv.excel):
656 delimiter = "\u039B"
657
658 class unspecified():
659 # A class to pass as dialect but with no dialect attributes.
660 pass
661
662 csv.register_dialect('testC', testC)
663 try:
664 self.compare_dialect_123("1,2,3\r\n")
665 self.compare_dialect_123("1,2,3\r\n", dialect=None)
666 self.compare_dialect_123("1,2,3\r\n", dialect=unspecified)
667 self.compare_dialect_123("1\t2\t3\r\n", testA)
668 self.compare_dialect_123("1:2:3\r\n", dialect=testB())
669 self.compare_dialect_123("1|2|3\r\n", dialect='testC')
670 self.compare_dialect_123("1;2;3\r\n", dialect=testA,
671 delimiter=';')
672 self.compare_dialect_123("1\u039B2\u039B3\r\n",
673 dialect=testUni)
674
675 finally:
676 csv.unregister_dialect('testC')
677
678 def test_copy(self):
679 for name in csv.list_dialects():

Callers

nothing calls this directly

Calls 2

compare_dialect_123Method · 0.95
testBClass · 0.85

Tested by

no test coverage detected