File: test_consistency.py

package info (click to toggle)
python-clevercsv 0.8.3%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,076 kB
  • sloc: python: 6,184; ansic: 870; makefile: 90
file content (27 lines) | stat: -rw-r--r-- 769 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-

"""
Unit test for consistency score

Author: G.J.J. van den Burg

"""

import unittest

from clevercsv.consistency import ConsistencyDetector
from clevercsv.consistency import ConsistencyScore
from clevercsv.dialect import SimpleDialect


class ConsistencyTestCase(unittest.TestCase):
    def test_get_best_set_1(self) -> None:
        scores = {
            SimpleDialect(",", None, None): ConsistencyScore(P=1, T=1, Q=1),
            SimpleDialect(";", None, None): ConsistencyScore(
                P=1, T=None, Q=None
            ),
            SimpleDialect("|", None, None): ConsistencyScore(P=2, T=1, Q=2),
        }
        H = ConsistencyDetector.get_best_dialects(scores)
        self.assertEqual(H, [SimpleDialect("|", None, None)])