예제 #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),
                             {})
예제 #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
     })
예제 #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
    }
예제 #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
         })
예제 #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})
예제 #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}
예제 #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})
예제 #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})
예제 #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), {})
예제 #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}
예제 #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) == {}
예제 #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) == {}
예제 #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}
예제 #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}
예제 #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}
예제 #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})
예제 #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), {})
예제 #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}
예제 #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})
예제 #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}
예제 #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})
예제 #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) == {}
예제 #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), {})
예제 #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) == {}