2020-11-19 18:43:10 +01:00
|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
Zadanie 109
|
|
|
|
|
|
|
|
Napisz funkcję `count_yes_lines(filename)`, która po podaniu nazwy pliku
|
|
|
|
tekstowego `filename` zwraca liczbę wierszy w pliku zawierających
|
|
|
|
(wyłącznie) napis "YES" (i znak końca wiersza).
|
|
|
|
|
|
|
|
NAME: count_yes_lines
|
|
|
|
PARAMS: string
|
|
|
|
RETURN: int
|
2020-11-19 18:44:35 +01:00
|
|
|
POINTS: 1
|
2020-11-19 18:43:10 +01:00
|
|
|
"""
|
|
|
|
import unittest
|
|
|
|
from Task109 import count_yes_lines
|
|
|
|
|
|
|
|
class Task109Test(unittest.TestCase):
|
|
|
|
"""Testy do zadania 109."""
|
|
|
|
|
|
|
|
def test_on_self(self):
|
|
|
|
"""Testy na samym sobie."""
|
|
|
|
self.failUnlessEqual(count_yes_lines("Task109Test.py"), 0)
|
|
|
|
|
|
|
|
def test_simple(self):
|
|
|
|
"""Testy na prostym pliku."""
|
|
|
|
self.failUnlessEqual(count_yes_lines("Task109Test.dat.txt"), 4)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|