Skip to content

Commit 7b097a8

Browse files
committed
Added more tests to String Indexing task, plus a couple of refactorings
1 parent 53c7b6e commit 7b097a8

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Strings/Concatenation/tests/test_task.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ def test_statement_1(self):
2020
with open("concatenation.py", "r") as taskfile:
2121
lines = taskfile.readlines()
2222
code = lines[-2]
23-
self.assertTrue("+" in code, msg="Your solution does not use concatenation.")
23+
if not ("+" in code):
24+
self.fail(msg="Your solution does not use string concatenation.")

Strings/String indexing/tests/test_task.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,16 @@ def test_indexing(self):
1010
except ImportError:
1111
self.assertTrue(False, msg="Do not rename any variables.")
1212

13+
def test_0_code_len(self):
14+
with open("string_indexing.py", "r") as taskfile:
15+
lines = taskfile.readlines()
16+
self.assertTrue(len(lines) == 5, msg="Please do not add or remove any lines from the code file.")
17+
18+
def test_statement_1(self):
19+
with open("string_indexing.py", "r") as taskfile:
20+
lines = taskfile.readlines()
21+
code = lines[-2]
22+
if not ("[0]" in code):
23+
self.fail(msg="Your solution does not use string indexing.")
1324

1425

Strings/String multiplication/tests/test_task.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ def test_statement_1(self):
1919
with open("string_multiplication.py", "r") as taskfile:
2020
lines = taskfile.readlines()
2121
code = lines[-2]
22-
self.assertTrue("*" in code, msg="Your solution does not use string multiplication.")
22+
if not ("*" in code):
23+
self.fail(msg="Your solution does not use string multiplication.")

0 commit comments

Comments
 (0)