Beispiel #1
0
 def test_register_kwargs(self):
     name = "fedcba"
     csv.register_dialect(name, delimiter=";")
     try:
         self.assertEqual(csv.get_dialect(name).delimiter, ";")
         self.assertEqual([["X", "Y", "Z"]], list(csv.reader(["X;Y;Z"], name)))
     finally:
         csv.unregister_dialect(name)
Beispiel #2
0
 def test_register_kwargs(self):
     name = 'fedcba'
     csv.register_dialect(name, delimiter=';')
     try:
         self.assertEqual(csv.get_dialect(name).delimiter, ';')
         self.assertEqual([['X', 'Y', 'Z']], list(csv.reader(['X;Y;Z'], name)))
     finally:
         csv.unregister_dialect(name)
Beispiel #3
0
 def test_register_kwargs(self):
     name = 'fedcba'
     csv.register_dialect(name, delimiter=';')
     try:
         self.assertEqual(csv.get_dialect(name).delimiter, ';')
         self.assertEqual([['X', 'Y', 'Z']],
                          list(csv.reader(['X;Y;Z'], name)))
     finally:
         csv.unregister_dialect(name)
Beispiel #4
0
    def test_registry(self):
        class myexceltsv(csv.excel):
            delimiter = "\t"

        name = "myexceltsv"
        expected_dialects = csv.list_dialects() + [name]
        expected_dialects.sort()
        csv.register_dialect(name, myexceltsv)
        self.addCleanup(csv.unregister_dialect, name)
        self.assertEqual(csv.get_dialect(name).delimiter, '\t')
        got_dialects = sorted(csv.list_dialects())
        self.assertEqual(expected_dialects, got_dialects)
Beispiel #5
0
 def test_registry(self):
     class myexceltsv(csv.excel):
         delimiter = "\t"
     name = "myexceltsv"
     expected_dialects = csv.list_dialects() + [name]
     expected_dialects.sort()
     csv.register_dialect(name, myexceltsv)
     try:
         self.assertEqual(csv.get_dialect(name).delimiter, '\t')
         got_dialects = sorted(csv.list_dialects())
         self.assertEqual(expected_dialects, got_dialects)
     finally:
         csv.unregister_dialect(name)