Skip to content

Commit 5268938

Browse files
committed
Added test that cheecks if variable age exists
1 parent f873f08 commit 5268938

File tree

2 files changed

+13
-1
lines changed
  • .learn/resets/05-User-Inputed-Values
  • exercises/05-User-Inputed-Values

2 files changed

+13
-1
lines changed

Diff for: .learn/resets/05-User-Inputed-Values/app.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
age = int(input('What is your age?\n'))
2+
# CHANGE THE CODE BELOW TO ADD 10 TO AGE
3+
4+
print("Your age is: "+str(age))

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

+9-1
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()')
@@ -18,3 +18,11 @@ def test_plus_ten(stdin):
1818
import app
1919
captured = buffer.getvalue()
2020
assert captured == "Your age is: 60\n"
21+
22+
@pytest.mark.it('There should be a variable named age')
23+
def test_variable_exists():
24+
try:
25+
import app
26+
app.age
27+
except AttributeError:
28+
raise AttributeError('The variable "age" should exist on app.py')

0 commit comments

Comments
 (0)