Skip to content

Commit 79d9012

Browse files
committed
Update HelloWorld to use the expect features.
1 parent 793e724 commit 79d9012

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

HelloWorld/challenge.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,24 @@ class HelloWorldChallenge(Challenge):
4343
5
4444
WorldHello
4545
'''
46+
4647
"""This is the input sample. It can be overwritten by injection.
4748
4849
* first line: integer
4950
* second line: word
51+
52+
It is used by the --klass option of the challenge runner.
53+
It can be used for unit tests.
54+
55+
prompt> challenge HelloWorld/ --klass
56+
Hello World
57+
"""
58+
59+
expect = 'Hello World'
60+
61+
"""This is the expected output for the sample.
62+
63+
It can be used for unit tests.
5064
"""
5165

5266
def build(self):

HelloWorld/test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@
44

55

66
class HelloWorldTest(unittest.TestCase):
7+
78
def setUp(self):
89
self.challenge = HelloWorldChallenge()
910

1011
def test__init__(self):
1112
self.assertIsInstance(self.challenge, HelloWorldChallenge)
13+
self.assertIn('WorldHello', self.challenge.sample)
14+
self.assertIn('Hello World', self.challenge.expect)
1215

1316
def test_build(self):
14-
self.challenge.lines = ['5', 'xxx']
17+
self.challenge.read()
1518
self.challenge.build()
1619
self.assertEqual(5, self.challenge.model.split_at)
17-
self.assertEqual('xxx', self.challenge.model.word)
20+
self.assertEqual('WorldHello', self.challenge.model.word)
1821

1922
def test_calc(self):
2023
self.challenge.model.split_at = 5
2124
self.challenge.model.word = 'honeymoon'
2225
self.challenge.calc()
2326
self.assertEqual('moon honey', self.challenge.result)
27+
28+
def test_full_integration(self):
29+
self.challenge.main()
30+
self.assertEqual(self.challenge.expectation(), self.challenge.output)

README.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ Features
6262
* Output formatted result on the command line
6363
* Writing `sample.txt` and matching `result.txt` into the challenges directory
6464
* Running the unit test case of a challenge
65+
* Reading lines with integers
66+
* Reading lines with floats
67+
* Reading lines with words
68+
* Reading fasta input
6569

6670
Directory layout
6771
================
@@ -305,4 +309,3 @@ alternatively as `stepik` or `rosalind`.
305309
306310
prompt> rosalind --version
307311
rosalind 0.6.0
308-

0 commit comments

Comments
 (0)