Skip to content

Commit 0f796f4

Browse files
Merge pull request #67 from UmiKami/01-Console---10-Calling-Your-First-Function
01 console 10 calling your first function
2 parents e84a372 + d4006fe commit 0f796f4

File tree

17 files changed

+71
-42
lines changed

17 files changed

+71
-42
lines changed

exercises/03-Print-Variables-In-The-Console/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_for_printing_variable():
1818

1919
with open(path, 'r') as content_file:
2020
content = content_file.read()
21-
regex = re.compile(r"print(\s*)\(\s*color\s*\)")
21+
regex = re.compile(r"print\s*\(\s*color\s*\)")
2222
assert bool(regex.search(content)) == True
2323

2424
@pytest.mark.it('The printed value on the console should be "red"')

exercises/04-Multiply-Two-Values/test.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@ def test_use_variable_name():
2323
@pytest.mark.it('Print on the console the variables_are_cool value ')
2424
def test_for_file_output(capsys):
2525
captured = buffer.getvalue()
26-
assert captured == '17172435\n'
26+
assert captured == '17172435\n'
27+
28+
@pytest.mark.it('Print on the console the variables_are_cool variable')
29+
def test_for_print():
30+
with open(path, 'r') as content_file:
31+
content = content_file.read()
32+
# makes sure we are calling print function with a variable and not the hard coded value
33+
regex = re.compile(r"print\s*\(\s*variables_are_cool\s*\)")
34+
assert bool(regex.search(content)) == True

exercises/05-User-Inputed-Values/test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ def test_for_file_output(capsys):
99
regex = re.compile(pattern)
1010
assert bool(regex.search(content)) == True
1111

12-
1312
@pytest.mark.it("We tried with age 50 and it was supposed to return 60")
1413
@mock.patch('builtins.input', lambda x: 50)
1514
def test_plus_ten(stdin):

exercises/06-String-Concatenation/test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def test_my_var1_exists():
1010
except ImportError:
1111
raise ImportError("The variable 'my_var1' should exist on app.py")
1212

13-
1413
@pytest.mark.it("Create a variable named my_var2")
1514
def test_my_var2_exists():
1615
try:
@@ -24,10 +23,18 @@ def test_my_var1_value():
2423
assert my_var1 == "Hello"
2524

2625
@pytest.mark.it("Variable my_var2 value should be 'World'")
27-
def test_my_var1_value():
26+
def test_my_var2_value():
2827
from app import my_var2
2928
assert my_var2 == "World"
3029

30+
@pytest.mark.it("Variable my_var2 value should be 'World'")
31+
def test_the_new_string_exists():
32+
import app
33+
try:
34+
app.the_new_string
35+
except AttributeError:
36+
raise AttributeError('The variable "the_new_string" should exist on app.py')
37+
3138
@pytest.mark.it('Print "Hello World" on the console')
3239
def test_for_file_output():
3340
captured = buffer.getvalue()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `08` Your First If...
1+
# `08.1` Your First If...
22

33
La aplicación actual está preguntando cuánto dinero tiene el usuario. Una vez el usuario ingresa la cantidad, debemos 'imprimir' usando **print** una de las siguientes respuestas:
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
tutorial: "https://www.youtube.com/watch?v=x9wqa5WQZiM"
33
---
44

5-
# `08` Your First if...
5+
# `08.1` Your First if...
66

77
The current application is prompting asking how much money the user has. Once the user inputs the amount, we need to **print** one of the following answers:
88

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
total = int(input('How much money do you have in your pocket\n'))
22

3-
# YOUR CODE HERE
3+
# YOUR CODE HERE
File renamed without changes.
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ def test_for_print(capsys):
1515
content = content_file.read()
1616
regex = re.compile(r"if\s*")
1717
regex2 = re.compile(r"elif\s*")
18-
assert bool(regex.search(content)) == True or bool(regex.search(content))==False
18+
assert ((bool(regex.search(content)) == True) and (bool(regex2.search(content))==True))
1919

2020
@pytest.mark.it('Use the function print()')
2121
def test_for_print(capsys):
2222
with open(path, 'r') as content_file:
2323
content = content_file.read()
24-
regex = re.compile(r"print\(.+\)")
24+
regex = re.compile(r"print\s*\(")
2525
assert bool(regex.search(content)) == True
2626

2727
@pytest.mark.it("When input for more than 100 it should print: Give me your money!")
@@ -64,8 +64,4 @@ def test_for_output_when_49(capsys, app):
6464
with mock.patch('builtins.input', lambda x: 49):
6565
app()
6666
captured = capsys.readouterr()
67-
assert "You are a poor guy, go away!\n" == captured.out
68-
69-
70-
71-
67+
assert "You are a poor guy, go away!\n" == captured.out

exercises/08.1-How-Much-The-Wedding-Costs/README.es.md renamed to exercises/08.2-How-Much-The-Wedding-Costs/README.es.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `08.1` Cuánto costará la boda (if...else)
1+
# `08.2` Cuánto costará la boda (if...else)
22

33
Aquí tenemos una tabla de precios de una compañía de catering de bodas:
44

0 commit comments

Comments
 (0)