File: test_consistency.py

package info (click to toggle)
python-clevercsv 0.7.5%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 872 kB
  • sloc: python: 5,076; ansic: 763; makefile: 81
file content (33 lines) | stat: -rw-r--r-- 919 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
28
29
30
31
32
33
# -*- coding: utf-8 -*-

"""
Unit test for consistency score

Author: G.J.J. van den Burg

"""

import unittest

from clevercsv.consistency import get_best_set
from clevercsv.dialect import SimpleDialect


class ConsistencyTestCase(unittest.TestCase):
    def test_get_best_set_1(self):
        scores = {
            SimpleDialect(",", None, None): {"Q": 1.0},
            SimpleDialect(";", None, None): {"Q": None},
            SimpleDialect("|", None, None): {"Q": 2.0},
        }
        H = get_best_set(scores)
        self.assertEqual(H, set([SimpleDialect("|", None, None)]))

    def test_get_best_set_2(self):
        scores = {
            SimpleDialect(";", None, None): {"Q": None},
            SimpleDialect(",", None, None): {"Q": 1.0},
            SimpleDialect("|", None, None): {"Q": 2.0},
        }
        H = get_best_set(scores)
        self.assertEqual(H, set([SimpleDialect("|", None, None)]))