Ejemplo n.º 1
0
    def test_count_by_if_increment_function_has_error_return_empty_dict(self):
        def increment(element):
            raise Exception(element)

        lista = [{'b': False}] * 4
        self.assertDictEqual(count_by(lista, lambda n: n, increment=increment),
                             {})
Ejemplo n.º 2
0
 def test_count_by_use_with_list_and_increment_with_value_return_count_incremented(
         self):
     lista = [2] * 5 + [1] * 4
     self.assertDictEqual(count_by(lista, lambda n: n, lambda n: n), {
         1: 4,
         2: 10
     })
Ejemplo n.º 3
0
def test_count_by_if_count_for_key_and_increment_with_value_should_return_key_count_incremented(
):
    array = [{'b': 1}] * 4 + [{'b': 2}] * 4
    assert count_by(array, lambda el: el['b'], lambda el: el['b']) == {
        '1': 4,
        '2': 8
    }
Ejemplo n.º 4
0
 def test_count_by_if_count_for_key_and_increment_with_value_return_key_count_incremented(
         self):
     lista = [{'b': 1}] * 4 + [{'b': 2}] * 4
     self.assertDictEqual(
         count_by(lista, lambda el: el['b'], lambda el: el['b']), {
             1: 4,
             2: 8
         })
Ejemplo n.º 5
0
 def test_count_by_if_count_for_key_return_key_count(self):
     lista = [{'b': 1}] * 4 + [{'b': 2}] * 4
     self.assertDictEqual(
         count_by(lista, lambda el: el['b']), {1: 4, 2: 4})
Ejemplo n.º 6
0
def test_count_by_if_count_for_key_should_return_key_count():
    array = [{'b': 1}] * 4 + [{'b': 2}] * 4
    assert count_by(array, lambda el: el['b']) == {'1': 4, '2': 4}
Ejemplo n.º 7
0
 def test_count_by_use_with_list_and_increment_with_value_return_count_incremented(self):
     lista = [2] * 5 + [1] * 4
     self.assertDictEqual(count_by(lista, lambda n: n, lambda n: n), {1: 4, 2: 10})
Ejemplo n.º 8
0
 def test_count_by_if_count_for_key_and_increment_with_value_return_key_count_incremented(self):
     lista = [{'b': 1}] * 4 + [{'b': 2}] * 4
     self.assertDictEqual(count_by(lista, lambda el: el['b'], lambda el: el['b']), {1: 4, 2: 8})
Ejemplo n.º 9
0
 def test_count_by_if_increment_function_has_error_return_empty_dict(self):
     def increment(element):
         raise Exception(element)
     lista = [{'b': False}] * 4
     self.assertDictEqual(count_by(lista, lambda n: n, increment=increment), {})
Ejemplo n.º 10
0
def test_count_by_if_count_for_key_should_return_key_count():
    array = [{'b': 1}] * 4 + [{'b': 2}] * 4
    assert count_by(array, lambda el: el['b']) == {'1': 4, '2': 4}
Ejemplo n.º 11
0
def test_count_by_if_increment_function_has_error_should_return_empty_dict():
    def increment(element):
        raise Exception(element)

    array = [{'b': False}] * 4
    assert count_by(array, lambda n: n, increment=increment) == {}
Ejemplo n.º 12
0
def test_count_by_with_getter_function_with_error_should_return_empty_dict():
    def getter(element):
        raise Exception(element)
    array = [{'b': False}] * 4
    assert count_by(array, getter) == {}
Ejemplo n.º 13
0
def test_count_by_use_with_list_and_increment_with_value_should_return_count_incremented():
    array = [2] * 5 + [1] * 4
    assert count_by(array, lambda n: n, lambda n: n) == {'1': 4, '2': 10}
Ejemplo n.º 14
0
def test_count_by_use_with_list_should_return_count():
    array = [2] * 5 + [1] * 4
    assert count_by(array, lambda n: n) == {'1': 4, '2': 5}
Ejemplo n.º 15
0
def test_count_by_if_count_for_key_and_increment_with_value_should_return_key_count_incremented():
    array = [{'b': 1}] * 4 + [{'b': 2}] * 4
    assert count_by(array, lambda el: el['b'], lambda el: el['b']) == {'1': 4, '2': 8}
Ejemplo n.º 16
0
 def test_count_by_use_with_list_return_count(self):
     lista = [2] * 5 + [1] * 4
     self.assertDictEqual(
         count_by(lista, lambda n: n), {1: 4, 2: 5})
Ejemplo n.º 17
0
 def test_count_by_if_getter_function_has_error_return_empty_dict(self):
     def getter(element):
         raise Exception(element)
     lista = [{'b': False}] * 4
     self.assertDictEqual(count_by(lista, getter), {})
Ejemplo n.º 18
0
def test_count_by_use_with_list_should_return_count():
    array = [2] * 5 + [1] * 4
    assert count_by(array, lambda n: n) == {'1': 4, '2': 5}
Ejemplo n.º 19
0
 def test_count_by_if_count_for_key_return_key_count(self):
     lista = [{'b': 1}] * 4 + [{'b': 2}] * 4
     self.assertDictEqual(count_by(lista, lambda el: el['b']), {1: 4, 2: 4})
Ejemplo n.º 20
0
def test_count_by_use_with_list_and_increment_with_value_should_return_count_incremented(
):
    array = [2] * 5 + [1] * 4
    assert count_by(array, lambda n: n, lambda n: n) == {'1': 4, '2': 10}
Ejemplo n.º 21
0
 def test_count_by_use_with_list_return_count(self):
     lista = [2] * 5 + [1] * 4
     self.assertDictEqual(count_by(lista, lambda n: n), {1: 4, 2: 5})
Ejemplo n.º 22
0
def test_count_by_with_getter_function_with_error_should_return_empty_dict():
    def getter(element):
        raise Exception(element)

    array = [{'b': False}] * 4
    assert count_by(array, getter) == {}
Ejemplo n.º 23
0
 def test_count_by_if_getter_function_has_error_return_empty_dict(self):
     def getter(element):
         raise Exception(element)
     lista = [{'b': False}] * 4
     self.assertDictEqual(count_by(lista, getter), {})
Ejemplo n.º 24
0
def test_count_by_if_increment_function_has_error_should_return_empty_dict():
    def increment(element):
        raise Exception(element)
    array = [{'b': False}] * 4
    assert count_by(array, lambda n: n, increment=increment) == {}