Skip to content
Open
Show file tree
Hide file tree
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
19 changes: 18 additions & 1 deletion src/additions/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,28 @@ def lottery():
# returns a 4th number between 10 and 20
yield random.randint(10, 20)


def generator(s):

for c in range(len(s)-1,-1,-1):
yield s[c]

def new_generator(n):
yield n+1
yield n+2

def test_generators():
"""Yield statement"""
for number_index, random_number in enumerate(lottery()):
if number_index < 3:
assert 0 <= random_number <= 10
else:
assert 10 <= random_number <= 20

output = ""
for c in generator("hello"):
output += c
assert output == "olleh"
test = new_generator(5)

assert next(test) == 6
assert next(test) == 7
6 changes: 5 additions & 1 deletion src/additions/test_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ def test_pass_in_loop():
# pylint: disable=too-few-public-methods
class MyEmptyClass:
"""PASS statement in class

"Pass" is commonly used for creating minimal classes like current one.
"""
num = 15

if num == 15:
pass
pass