Skip to content

Commit 606f85e

Browse files
committed
map list
1 parent 9730b61 commit 606f85e

File tree

57 files changed

+191
-227
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+191
-227
lines changed

exercises/01-hello-world/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
#You have to print `hello` in the console, your code go here:
2-
print("hello")
4+
print("Hello World")
35

exercises/01-hello-world/test.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import io
22
import sys
3+
import os
34
sys.stdout = buffer = io.StringIO()
45

56
# from app import my_function
@@ -21,8 +22,15 @@
2122
# def test_for_function_return(capsys):
2223
# assert my_function() == True
2324

24-
@pytest.mark.it("Output 'Hello'")
25+
@pytest.mark.it("Output 'Hello World'")
2526
def test_output():
2627
captured = buffer.getvalue()
27-
assert "hello\n" in captured
28-
# convert everything in the buffer to lower case, captured to lower case
28+
assert "Hello World\n" in captured
29+
# convert everything in the buffer to lower case, captured to lower case
30+
31+
32+
@pytest.mark.it("Use print function")
33+
def test_print():
34+
f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py')
35+
content = f.read()
36+
assert content.find("print") > 0

exercises/01.1-Access-and-Retrieve/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday']
33

44
#1. print the item here
5-
print(my_list[2])
5+
66
#2. change 'thursday'a value here to None
7-
my_list[4] = None
7+
88
#3. print the position of step 2
9-
print(my_list[4])
9+
1010

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
my_list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23]
22

33
#output the 1st and 4th element from the list:
4-
print(my_list[0])
5-
print(my_list[3])
4+
65

exercises/01.3-Print-the-last-one/app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,3 @@ def generate_random_list():
1212
my_stupid_list = generate_random_list()
1313

1414
#Feel happy to write the code below, good luck:
15-
the_last_one = my_stupid_list[-1]
16-
print(the_last_one)

exercises/01.3-Print-the-last-one/test.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@
33
import app
44
import pytest
55

6+
import os
67
from app import the_last_one
78

9+
810
sys.stdout = buffer = io.StringIO()
911

1012
@pytest.mark.it("create and assign the value to the variable the_last_one")
1113
def test_create_assign():
1214
assert app.the_last_one is not None
1315

1416

15-
@pytest.mark.it("print in the console the_last_one")
16-
def test_output():
17-
captured = buffer.getvalue()
18-
assert str(app.the_last_one) in captured
17+
# @pytest.mark.it("print in the console the_last_one")
18+
# def test_output():
19+
# captured = buffer.getvalue()
20+
# assert str(app.the_last_one) in captured
21+
22+
@pytest.mark.it("Import random function")
23+
def test_import_random():
24+
f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py')
25+
content = f.read()
26+
assert content.find("import random") > 0
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#Remember import random function here:
2-
import random
2+
33

44
my_list = [4,5,734,43,45]
55

66
#The magic is here:
7-
for num in range(1, 11):
8-
my_list.append(random.randint(1, 100))
7+
8+
99

1010
print(my_list)

exercises/01.4-Add-item-to-list/test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import pytest
66
import app
7+
import os
78
import random
89
from app import my_list
910

@@ -14,4 +15,10 @@ def test_add_numb():
1415
@pytest.mark.it("Output of the list with 15 items numbers")
1516
def test_output():
1617
captured = buffer.getvalue()
17-
assert str(app.my_list) in captured
18+
assert str(app.my_list) in captured
19+
20+
@pytest.mark.it("Import random function")
21+
def test_import_random():
22+
f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py')
23+
content = f.read()
24+
assert content.find("import random") > 0
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
#Your code here, have fun:
2-
for numb in range(1,18):
3-
print(numb)

exercises/01.5-loop-seventeen/test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ def test_output():
1414

1515

1616

17-
@pytest.mark.it("Make sure that there is a 'for loop' in your code")
17+
@pytest.mark.it("Make sure that you use for loop!!!")
1818
def test_for_loop():
19-
captured = buffer.getvalue()
2019

2120
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
2221
content = f.read()
23-
assert content.find("for ") > 0
22+
assert content.find("for") > 0

0 commit comments

Comments
 (0)