def test_evens():
    l = [-7.22, -6.10, -5.00, -4.00, -3.0, -2.0, -1, 0, 1, 2, 3, 4, 5, 6, 7]
    assert count_evens(l) == 6

    with pytest.raises(TypeError):
        l = ['0', '1', '2', 3, 4]
        assert count_evens(l) == 1
def test_count_evens():
    assert count_evens([2, 1, 2, 3, 4]) == 3
    assert count_evens([2, 2, 0]) == 3
    assert count_evens([1, 3, 5]) == 0
    assert count_evens([1, 2, 3, 4, 5, 6]) == 2
    assert count_evens([6, 5, 4, 3, 2, 1]) == 3
    assert count_evens([2, 2, 2]) == 3
    assert count_evens([4, 3, 5]) == 1
    assert count_evens([12, 13, 14]) == 2
    assert count_evens([54, 33, 5, 78, 4]) == 3
    assert count_evens([1, 31, 5, 7, 9, 77, 31, 55]) == 0
Beispiel #3
0
 def test_2_1_2_3_4_returns_3(self):
     actual = count_evens([2, 1, 2, 3, 4])
     expected = 3
     self.assertEqual(
         actual, expected,
         'Expected calling count_evens() with [2, 1, 2, 3, 4] to return "3"'
     )
Beispiel #4
0
 def test_empty_array_returns_0(self):
     actual = count_evens([])
     expected = 0
     self.assertEqual(
         actual, expected,
         'Expected calling count_evens() with [] to return "0"')
Beispiel #5
0
def test_7():
    assert count_evens([2, 5, 12]) == 2
Beispiel #6
0
def test_5():
    assert count_evens([11, 9, 0, 1]) == 1
Beispiel #7
0
def test_3():
    assert count_evens([2, 6, 8, 10]) == 4
Beispiel #8
0
def test_1():
    assert count_evens([2, 1, 2, 3, 4]) == 3
def test_evens():
    x = [1, 2, 3, 4, 5, 7]
    assert count_evens(x) == 2
def test_2():
    assert count_evens([2, 2, 0]) == 3
def test_1():
    assert count_evens([2, 1, 2, 3, 4]) == 3
Beispiel #12
0
 def test_2_5_12_returns_2(self):
     actual = count_evens([2, 5, 12])
     expected = 2
     self.assertEqual(
         actual, expected,
         'Expected calling count_evens() with [2, 5, 12] to return "2"')
Beispiel #13
0
 def test_2_returns_1(self):
     actual = count_evens([2])
     expected = 1
     self.assertEqual(
         actual, expected,
         'Expected calling count_evens() with [2] to return "1"')
Beispiel #14
0
 def test_2_11_9_0_returns_2(self):
     actual = count_evens([2, 11, 9, 0])
     expected = 2
     self.assertEqual(
         actual, expected,
         'Expected calling count_evens() with [2, 11, 9, 0] to return "2"')
Beispiel #15
0
 def test_11_9_0_1_returns_1(self):
     actual = count_evens([11, 9, 0, 1])
     expected = 1
     self.assertEqual(
         actual, expected,
         'Expected calling count_evens() with [11, 9, 0, 1] to return "1"')
Beispiel #16
0
def test_3():
    count_evens([1, 3, 5, -9, -3]) == 0
Beispiel #17
0
def test_4():
    count_evens([1, 3, 5, -9, -3, -4, -2]) == 2
def test_3():
    count_evens([1, 3, 5, -9, -3]) == 0
Beispiel #19
0
"""
test code from count evens on coding bat

Return the number of even ints in the given array. Note: the % "mod" operator computes the remainder, e.g. 5 % 2 is 1.


count_evens([2, 1, 2, 3, 4]) → 3
count_evens([2, 2, 0]) → 3
count_evens([1, 3, 5]) → 0

"""
from count_evens import count_evens


def test_1():
    assert count_evens([2, 1, 2, 3, 4]) == 3


def test_2():
    assert count_evens([2, 2, 0]) == 3


def test_3():
    assert count_evens([2, 6, 8, 10]) == 4


def test_4():
    assert count_evens([1, 3, 5]) == 0

def test_4():
    count_evens([1, 3, 5, -9, -3, -4, -2]) == 2
Beispiel #21
0
def test_2():
    assert count_evens([2, 2, 0]) == 3
Beispiel #22
0
def test_count_evens_5():
    assert count_evens([]) == 0
Beispiel #23
0
def test_4():
    assert count_evens([1, 3, 5]) == 0
Beispiel #24
0
def test_1():
    assert count_evens([1,2,3]) == 1
Beispiel #25
0
def test_6():
    assert count_evens([2, 11, 9, 0]) == 2
Beispiel #26
0
def test_2():
    assert count_evens([1,4,6,0]) == 3
Beispiel #27
0
def test_8():
    assert count_evens([2]) == 1
def test_2():
    ANS = None
    input = ['2', '1', '2']
    res = count_evens(input)
    assert res is ANS
def test_1():
    ANS = 3
    res = count_evens([2, 1, 2, 4])
    assert res is ANS
Beispiel #30
0
 def test_1_3_5_returns_0(self):
     actual = count_evens([1, 3, 5])
     expected = 0
     self.assertEqual(
         actual, expected,
         'Expected calling count_evens() with [1, 3, 5] to return "0"')