Skip to content

Commit d4006fe

Browse files
Conflict solved
2 parents 26f9553 + e84a372 commit d4006fe

File tree

14 files changed

+34
-41
lines changed

14 files changed

+34
-41
lines changed

Diff for: .gitpod.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ FROM gitpod/workspace-full:latest
33
USER gitpod
44

55
RUN pip3 install pytest==4.6.0 pytest-testdox mock
6-
RUN npm i @learnpack/learnpack -g && learnpack plugins:install learnpack-python@0.0.35
6+
RUN npm i @learnpack/learnpack@2.1.18 -g && learnpack plugins:install @learnpack/python

Diff for: exercises/02-Declare-Variables/test.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,5 @@ def test_for_variable():
2828
def test_for_file_output(capsys):
2929
captured = buffer.getvalue()
3030
assert captured == "Yellow\n" #add \n because the console jumps the line on every print
31-
def test_for_print():
31+
3232

33-
with open(path, 'r') as content_file:
34-
content = content_file.read()
35-
# makes sure we are calling print function with a variable and not the hard coded string
36-
regex = re.compile(r"print\s*\(\s*[^\d\W][_a-zA-Z0-9]*\s*\)\s*")
37-
assert bool(regex.search(content)) == True

Diff for: exercises/04-Multiply-Two-Values/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ def test_for_print():
3131
content = content_file.read()
3232
# makes sure we are calling print function with a variable and not the hard coded value
3333
regex = re.compile(r"print\s*\(\s*variables_are_cool\s*\)")
34-
assert bool(regex.search(content)) == True
34+
assert bool(regex.search(content)) == True

Diff for: exercises/05-User-Inputed-Values/test.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pytest,os,re,io,sys,mock,json
1+
import pytest,os,re,io,sys,mock,json
22
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
33

44
@pytest.mark.it('Use the function print()')
@@ -17,11 +17,4 @@ def test_plus_ten(stdin):
1717
import app
1818
captured = buffer.getvalue()
1919
assert captured == "Your age is: 60\n"
20-
21-
@pytest.mark.it('There should be a variable named age')
22-
def test_variable_exists():
23-
try:
24-
import app
25-
app.age
26-
except AttributeError:
27-
raise AttributeError('The variable "age" should exist on app.py')
20+

Diff for: exercises/06-String-Concatenation/test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import io, sys, os, re, pytest
22
sys.stdout = buffer = io.StringIO()
3-
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
3+
44
import app
55

66
@pytest.mark.it("Create a variable named my_var1")

Diff for: exercises/07-Create-a-Basic-HTML/test.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
sys.stdout = buffer = io.StringIO()
33
import app
44

5-
@pytest.mark.it('Use the function print()')
6-
def test_for_print():
7-
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
8-
with open(path, 'r') as content_file:
9-
content = content_file.read()
10-
regex = re.compile(r"print\s*\(.+\)")
11-
assert bool(regex.search(content)) == True
12-
135
@pytest.mark.it("Create a variable named html_document")
146
def test_html_document_exists():
157
try:
168
from app import html_document
179
except ImportError:
1810
raise ImportError("The variable 'html_document' should exist on app.py")
1911

12+
@pytest.mark.it("The value of html_document should be the expected")
13+
def test_html_document_exists():
14+
try:
15+
from app import html_document
16+
assert html_document == '<html><head><title></title></head><body></body></html>'
17+
except ImportError:
18+
raise ImportError("The variable 'html_document' should exist on app.py")
19+
2020
@pytest.mark.it('Concatenate all the variables together (in the right order) to set the value of html_document')
2121
def test_for_concat():
2222
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
@@ -30,4 +30,4 @@ def test_for_concat():
3030
@pytest.mark.it('Print a basic html layout on the console like this: <html><head><title></title></head><body></body></html>')
3131
def test_for_file_output():
3232
captured = buffer.getvalue()
33-
assert captured == "<html><head><title></title></head><body></body></html>\n" #add \n because the console jumps the line on every print
33+
assert captured == "<html><head><title></title></head><body></body></html>\n" #add \n because the console jumps the line on every print

Diff for: exercises/08.2-How-Much-The-Wedding-Costs/test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ def test_less_than_50(capsys, app):
3939
app()
4040
captured = capsys.readouterr()
4141
price = 4000
42-
assert "Your wedding will cost "+str(price)+" dollars\n" == captured.out
42+
"Your wedding will cost "+str(price)+" dollars\n" == captured.out
4343

4444
@pytest.mark.it("More than 200 should be priced 20,000")
4545
def test_t(capsys, app):
4646
with mock.patch('builtins.input', lambda x: 201):
4747
app()
4848
captured = capsys.readouterr()
4949
price = 20000
50-
assert "Your wedding will cost "+str(price)+" dollars\n" == captured.out
50+
"Your wedding will cost "+str(price)+" dollars\n" == captured.out

Diff for: exercises/10-Calling-Your-First-Function/test.py

-7
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,3 @@ def test_for_file_output(capsys):
3636
captured = capsys.readouterr()
3737
assert captured.out == "True\n"
3838

39-
@pytest.mark.it('You should not hardcode the expected output value on print() function')
40-
def test_for_hardcode_on_print():
41-
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
42-
with open(path, 'r') as content_file:
43-
content = content_file.read()
44-
regex = re.compile(r"print\s*\(\s*\bTrue\b\s*\)")
45-
assert bool(regex.search(content)) == False

Diff for: exercises/17-Russian-Roulette/test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def test_function_fire_gun(capsys, app):
1919
@pytest.mark.it('The function fire_gun should return the expected output in both cases')
2020
def test_function_output(capsys, app):
2121
if(app.spin_chamber() == app.bullet_position):
22-
assert "You're dead!"
22+
assert app.fire_gun() == "You are dead!"
2323
else:
24-
assert "Keep playing!"
24+
assert app.fire_gun() == "Keep playing!"
2525

2626
@pytest.mark.it('Your code needs to print the correct output on the console')
2727
def test_for_file_output(capsys):

Diff for: exercises/18-The-Beatles/test.py

+8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ def test_function_sing_exists(app):
1515
except AttributeError:
1616
raise AttributeError("The function 'sing' should exist on app.py")
1717

18+
@pytest.mark.it("You should not be hard coding the output")
19+
def test_function_hardcode_output():
20+
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
21+
with open(path, 'r') as content_file:
22+
content = content_file.read()
23+
regex = re.compile(r"\breturn\s*[^\"][a-zA-Z0-9]*\b\s*")
24+
assert bool(regex.search(content)) == True
25+
1826
@pytest.mark.it("The function sing should return astring with the song lyrics")
1927
def test_function_sing_exists(app):
2028
try:

Diff for: exercises/19-Bottles-Of-Milk/README.es.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ Go to the store and buy some more, 99 bottles of milk on the wall.
3333

3434
+ Al final de la canción, la letra cambia porque es solo una botella (singular en lugar del plural).
3535

36-
+ Lee la última parte de la letra y verás como cambia la última línea a "go to the store and by some more".
36+
+ Lee la última parte de la letra y verás como cambia la última línea a `"go to the store and by some more"`.

Diff for: exercises/19-Bottles-Of-Milk/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ Go to the store and buy some more, 99 bottles of milk on the wall.
3737

3838
+ At the end of the song, the lyrics change because is only one bottle (singular instead of plural).
3939

40-
+ Read the last lyrics and you will see how the last line changes to `"go to the store and by some more"`.
40+
+ Read the last lyrics and you will see how the last line changes to `"go to the store and buy some more"`.

Diff for: exercises/19-Bottles-Of-Milk/app.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Your code here!

Diff for: exercises/19-Bottles-Of-Milk/test.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99

1010
@pytest.mark.it('The function number_of_bottles must exist')
1111
def test_function_spin_chamber(capsys, app):
12-
assert app.number_of_bottles
12+
try:
13+
app.number_of_bottles
14+
except AttributeError:
15+
raise AttributeError("The function number_of_bottles should exist")
1316

1417
@pytest.mark.it('The function must return the expected output')
1518
def test_for_function_output(capsys):

0 commit comments

Comments
 (0)