From 81398516f75e6b303d0b22157129189d8ed7b555 Mon Sep 17 00:00:00 2001 From: iminlan <38048764+iminlan@users.noreply.github.com> Date: Sat, 23 Jun 2018 21:35:54 +0500 Subject: [PATCH 1/3] leap_year --- homework/tests.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/homework/tests.py b/homework/tests.py index d4926c7..d1a8178 100644 --- a/homework/tests.py +++ b/homework/tests.py @@ -1,4 +1,5 @@ import datetime +import re def test_leap_year(): @@ -12,7 +13,11 @@ def test_leap_year(): """ def is_leap_year(date): - pass + a = date.year + if (((a % 400) == 0) or (((a % 4) == 0) and ((a % 100) != 0))): + return True + else: + return False assert is_leap_year(datetime.date(year=2000, month=5, day=13)) assert is_leap_year(datetime.date(year=2016, month=11, day=1)) @@ -33,7 +38,13 @@ def test_file_data(): """ def count_word_in_file(filename, word): - pass + num = 0 + with open(filename) as u: + for line in u: + text_words = list(re.findall(r'\w+', line.casefold())) #ищем слова + num += text_words.count(word) + u.close() + return num assert count_word_in_file("homework/pony.txt", "радуга") == 0 assert count_word_in_file("homework/pony.txt", "и") == 3 From d1234e08a753abbeb6e701a5faba269ff2ae3547 Mon Sep 17 00:00:00 2001 From: iminlan <38048764+iminlan@users.noreply.github.com> Date: Mon, 25 Jun 2018 20:56:01 +0500 Subject: [PATCH 2/3] Update tests.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit убрала закрытие файла --- homework/tests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homework/tests.py b/homework/tests.py index d1a8178..57970f5 100644 --- a/homework/tests.py +++ b/homework/tests.py @@ -43,7 +43,6 @@ def count_word_in_file(filename, word): for line in u: text_words = list(re.findall(r'\w+', line.casefold())) #ищем слова num += text_words.count(word) - u.close() return num assert count_word_in_file("homework/pony.txt", "радуга") == 0 From f1570d40b8cd422b192847ecb9ffe9af68da9b80 Mon Sep 17 00:00:00 2001 From: iminlan <38048764+iminlan@users.noreply.github.com> Date: Wed, 27 Jun 2018 11:46:31 +0500 Subject: [PATCH 3/3] Update tests.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Для искомого слова тоже убрала регистрозависимость --- homework/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homework/tests.py b/homework/tests.py index 57970f5..12e0862 100644 --- a/homework/tests.py +++ b/homework/tests.py @@ -42,7 +42,7 @@ def count_word_in_file(filename, word): with open(filename) as u: for line in u: text_words = list(re.findall(r'\w+', line.casefold())) #ищем слова - num += text_words.count(word) + num += text_words.count(word.casefold()) return num assert count_word_in_file("homework/pony.txt", "радуга") == 0