portfoliome /
foil
| 1 | import unittest |
||
|
0 ignored issues
–
show
|
|||
| 2 | |||
| 3 | from foil.counting import count_by |
||
| 4 | |||
| 5 | |||
| 6 | class TestCounting(unittest.TestCase): |
||
| 7 | def test_count_by(self): |
||
| 8 | field_name = 'field' |
||
| 9 | records = [{field_name: 'a'}, {field_name: 'b'}, {field_name: 'a'}] |
||
| 10 | |||
| 11 | expected = {'a': 2, 'b': 1} |
||
| 12 | result = count_by(records, field_name) |
||
| 13 | self.assertDictEqual(expected, result) |
||
| 14 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.