Skip to content
This repository was archived by the owner on Oct 16, 2019. It is now read-only.

Test№01 #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions homework/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ def test_leap_year():
"""

def is_leap_year(date):
pass
if date.year % 100 == 0:
if date.year % 400 == 0:
return True
else: return False
else:
if date.year % 4 == 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))
Expand All @@ -33,8 +40,10 @@ def test_file_data():
"""

def count_word_in_file(filename, word):
pass

f = open('filename', 'r')
i = f.split
i.count(word)
return count
assert count_word_in_file("homework/pony.txt", "радуга") == 0
assert count_word_in_file("homework/pony.txt", "и") == 3
assert count_word_in_file("homework/pony.txt", "пони") == 5