Skip to content

Commit b1fc9e8

Browse files
authored
Changed test error messages and touched up docs. (#3541)
[no important files changed]
1 parent c5bfa4c commit b1fc9e8

File tree

5 files changed

+79
-48
lines changed

5 files changed

+79
-48
lines changed

exercises/concept/little-sisters-vocab/.docs/hints.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## General
44

5-
- The [Python Docs Tutorial for strings][python-str-doc] has an overview of the Python `str` type.
6-
- String methods [<str>.join()][str-join] and [<str>.split()][str-split] ar very helpful when processing strings.
7-
- The [Python Docs on Sequence Types][common sequence operations] has a rundown of operations common to all sequences, including `strings`, `lists`, `tuples`, and `ranges`.
5+
- The Python Docs [Tutorial for strings][python-str-doc] has an overview of the Python `str` type.
6+
- String methods [`str.join()`][str-join] and [`str.split()`][str-split] ar very helpful when processing strings.
7+
- The Python Docs on [Sequence Types][common sequence operations] has a rundown of operations common to all sequences, including `strings`, `lists`, `tuples`, and `ranges`.
88

99
There's four activities in the assignment, each with a set of text or words to work with.
1010

@@ -14,24 +14,24 @@ There's four activities in the assignment, each with a set of text or words to w
1414

1515
## 2. Add prefixes to word groups
1616

17-
- Believe it or not, `<str>.join()` is all you need.
18-
- Like `<str>.split()`, `<str>.join()` can take an arbitrary-length string, made up of any unicode code points.
17+
- Believe it or not, [`str.join()`][str-join] is all you need here.
18+
- Like [`str.split()`][str-split]`, `str.join()` can take an arbitrary-length string, made up of any unicode code points.
1919

2020
## 3. Remove a suffix from a word
2121

22-
- Strings can be both indexed and sliced from either the left (starting at 0) or the right (starting at -1).
22+
- Strings can be indexed or sliced from either the left (starting at 0) or the right (starting at -1).
2323
- If you want the last code point of an arbitrary-length string, you can use [-1].
2424
- The last three letters in a string can be "sliced off" using a negative index. e.g. 'beautiful'[:-3] == 'beauti'
2525

2626
## 4. Extract and transform a word
2727

28-
- Using `<str>.split()` returns a list of strings broken on white space.
28+
- Using [`str.split()`][str-split] returns a `list` of strings broken on white space.
2929
- `lists` are sequences, and can be indexed.
30-
- `<str>.split()` can be direcly indexed. e.g. `'Exercism rocks!'.split()[0] == 'Exercism'`
30+
- [`str.split()`][str-split] can be directly indexed: `'Exercism rocks!'.split()[0] == 'Exercism'`
3131
- Be careful of punctuation! Periods can be removed via slice: `'dark.'[:-1] == 'dark'`
3232

33-
[python-str-doc]: https://docs.python.org/3/tutorial/introduction.html#strings
3433

3534
[common sequence operations]: https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str
35+
[python-str-doc]: https://docs.python.org/3/tutorial/introduction.html#strings
3636
[str-join]: https://docs.python.org/3/library/stdtypes.html#str.join
3737
[str-split]: https://docs.python.org/3/library/stdtypes.html#str.split

exercises/concept/little-sisters-vocab/.docs/instructions.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Instructions
22

3-
You are helping your younger sister with her English vocabulary homework, which she's finding very tedious.
3+
You are helping your younger sister with her English vocabulary homework, which she is finding very tedious.
44
Her class is learning to create new words by adding _prefixes_ and _suffixes_.
55
Given a set of words, the teacher is looking for correctly transformed words with correct spelling by adding the prefix to the beginning or the suffix to the ending.
66

@@ -12,7 +12,7 @@ There's four activities in the assignment, each with a set of text or words to w
1212
One of the most common prefixes in English is `un`, meaning "not".
1313
In this activity, your sister needs to make negative, or "not" words by adding `un` to them.
1414

15-
Implement the `add_prefix_un()` function that takes `word` as a parameter and returns a new `un` prefixed word:
15+
Implement the `add_prefix_un(<word>)` function that takes `word` as a parameter and returns a new `un` prefixed word:
1616

1717

1818
```python
@@ -63,7 +63,7 @@ Implement the `make_word_groups(<vocab_words>)` function that takes a `vocab_wor
6363
But of course there are pesky spelling rules: If the root word originally ended in a consonant followed by a 'y', then the 'y' was changed to 'i'.
6464
Removing 'ness' needs to restore the 'y' in those root words. e.g. `happiness` --> `happi` --> `happy`.
6565

66-
Implement the `remove_suffix_ness(<word>)` function that takes in a word `str`, and returns the root word without the `ness` suffix.
66+
Implement the `remove_suffix_ness(<word>)` function that takes in a `word`, and returns the root word without the `ness` suffix.
6767

6868

6969
```python
@@ -76,7 +76,7 @@ Implement the `remove_suffix_ness(<word>)` function that takes in a word `str`,
7676

7777
## 4. Extract and transform a word
7878

79-
Suffixes are often used to change the part of speech a word has.
79+
Suffixes are often used to change the part of speech a word is assigned to.
8080
A common practice in English is "verbing" or "verbifying" -- where an adjective _becomes_ a verb by adding an `en` suffix.
8181

8282
In this task, your sister is going to practice "verbing" words by extracting an adjective from a sentence and turning it into a verb.

exercises/concept/little-sisters-vocab/.docs/introduction.md

-1
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,3 @@ Strings support all [common sequence operations][common sequence operations].
228228
[str-split]: https://docs.python.org/3/library/stdtypes.html#str.split
229229
[text sequence]: https://docs.python.org/3/library/stdtypes.html#text-sequence-type-str
230230
[unicode code points]: https://stackoverflow.com/questions/27331819/whats-the-difference-between-a-character-a-code-point-a-glyph-and-a-grapheme
231-

exercises/concept/little-sisters-vocab/.meta/config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"authors": [
33
"aldraco",
4-
"bethanyg"
4+
"BethanyG"
55
],
66
"files": {
77
"solution": [

exercises/concept/little-sisters-vocab/strings_test.py

+65-33
Original file line numberDiff line numberDiff line change
@@ -12,65 +12,93 @@ class LittleSistersVocabTest(unittest.TestCase):
1212
def test_add_prefix_un(self):
1313
input_data = ['happy', 'manageable', 'fold', 'eaten', 'avoidable', 'usual']
1414
result_data = [f'un{item}' for item in input_data]
15-
number_of_variants = range(1, len(input_data) + 1)
1615

17-
for variant, word, result in zip(number_of_variants, input_data, result_data):
18-
with self.subTest(f'variation #{variant}', word=word, result=result):
19-
self.assertEqual(add_prefix_un(word), result,
20-
msg=f'Expected: {result} but got a different word instead.')
16+
for variant, (word, expected) in enumerate(zip(input_data, result_data), start=1):
17+
with self.subTest(f'variation #{variant}', word=word, expected=expected):
18+
19+
actual_result = add_prefix_un(word)
20+
error_message = (f'Called add_prefix_un("{word}"). '
21+
f'The function returned "{actual_result}", but the '
22+
f'tests expected "{expected}" after adding "un" as a prefix.')
23+
24+
self.assertEqual(actual_result, expected, msg=error_message)
2125

2226
@pytest.mark.task(taskno=2)
2327
def test_make_word_groups_en(self):
2428
input_data = ['en', 'circle', 'fold', 'close', 'joy', 'lighten', 'tangle', 'able', 'code', 'culture']
25-
result_data = ('en :: encircle :: enfold :: enclose :: enjoy :: enlighten ::'
29+
expected = ('en :: encircle :: enfold :: enclose :: enjoy :: enlighten ::'
2630
' entangle :: enable :: encode :: enculture')
2731

28-
self.assertEqual(make_word_groups(input_data), result_data,
29-
msg=f'Expected {result_data} but got something else instead.')
32+
actual_result = make_word_groups(input_data)
33+
error_message = (f'Called make_word_groups({input_data}). '
34+
f'The function returned "{actual_result}", '
35+
f'but the tests expected "{expected}" for the '
36+
'word groups.')
37+
38+
self.assertEqual(actual_result, expected, msg=error_message)
3039

3140
@pytest.mark.task(taskno=2)
3241
def test_make_word_groups_pre(self):
3342
input_data = ['pre', 'serve', 'dispose', 'position', 'requisite', 'digest',
3443
'natal', 'addressed', 'adolescent', 'assumption', 'mature', 'compute']
35-
result_data = ('pre :: preserve :: predispose :: preposition :: prerequisite :: '
36-
'predigest :: prenatal :: preaddressed :: preadolescent :: preassumption :: '
37-
'premature :: precompute')
44+
expected = ('pre :: preserve :: predispose :: preposition :: prerequisite :: '
45+
'predigest :: prenatal :: preaddressed :: preadolescent :: preassumption :: '
46+
'premature :: precompute')
47+
48+
actual_result = make_word_groups(input_data)
49+
error_message = (f'Called make_word_groups({input_data}). '
50+
f'The function returned "{actual_result}", '
51+
f'but the tests expected "{expected}" for the '
52+
'word groups.')
3853

39-
self.assertEqual(make_word_groups(input_data), result_data,
40-
msg=f'Expected {result_data} but got something else instead.')
54+
self.assertEqual(actual_result, expected, msg=error_message)
4155

4256
@pytest.mark.task(taskno=2)
4357
def test_make_word_groups_auto(self):
4458
input_data = ['auto', 'didactic', 'graph', 'mate', 'chrome', 'centric', 'complete',
4559
'echolalia', 'encoder', 'biography']
46-
result_data = ('auto :: autodidactic :: autograph :: automate :: autochrome :: '
47-
'autocentric :: autocomplete :: autoecholalia :: autoencoder :: '
48-
'autobiography')
60+
expected = ('auto :: autodidactic :: autograph :: automate :: autochrome :: '
61+
'autocentric :: autocomplete :: autoecholalia :: autoencoder :: '
62+
'autobiography')
4963

50-
self.assertEqual(make_word_groups(input_data), result_data,
51-
msg=f'Expected {result_data} but got something else instead.')
64+
actual_result = make_word_groups(input_data)
65+
error_message = (f'Called make_word_groups({input_data}). '
66+
f'The function returned "{actual_result}", '
67+
f'but the tests expected "{expected}" for the '
68+
'word groups.')
69+
70+
self.assertEqual(actual_result, expected, msg=error_message)
5271

5372
@pytest.mark.task(taskno=2)
5473
def test_make_words_groups_inter(self):
5574
input_data = ['inter', 'twine', 'connected', 'dependent', 'galactic', 'action',
5675
'stellar', 'cellular', 'continental', 'axial', 'operative', 'disciplinary']
57-
result_data = ('inter :: intertwine :: interconnected :: interdependent :: '
58-
'intergalactic :: interaction :: interstellar :: intercellular :: '
59-
'intercontinental :: interaxial :: interoperative :: interdisciplinary')
76+
expected = ('inter :: intertwine :: interconnected :: interdependent :: '
77+
'intergalactic :: interaction :: interstellar :: intercellular :: '
78+
'intercontinental :: interaxial :: interoperative :: interdisciplinary')
79+
80+
actual_result = make_word_groups(input_data)
81+
error_message = (f'Called make_word_groups({input_data}). '
82+
f'The function returned "{actual_result}", '
83+
f'but the tests expected "{expected}" for the '
84+
'word groups.')
6085

61-
self.assertEqual(make_word_groups(input_data), result_data,
62-
msg=f'Expected {result_data} but got something else instead.')
86+
self.assertEqual(actual_result, expected, msg=error_message)
6387

6488
@pytest.mark.task(taskno=3)
6589
def test_remove_suffix_ness(self):
6690
input_data = ['heaviness', 'sadness', 'softness', 'crabbiness', 'lightness', 'artiness', 'edginess']
6791
result_data = ['heavy', 'sad', 'soft', 'crabby', 'light', 'arty', 'edgy']
68-
number_of_variants = range(1, len(input_data) + 1)
6992

70-
for variant, word, result in zip(number_of_variants, input_data, result_data):
71-
with self.subTest(f'variation #{variant}', word=word, result=result):
72-
self.assertEqual(remove_suffix_ness(word), result,
73-
msg=f'Expected: {result} but got a different word instead.')
93+
for variant, (word, expected) in enumerate(zip(input_data, result_data), start=1):
94+
with self.subTest(f'variation #{variant}', word=word, expected=expected):
95+
actual_result = remove_suffix_ness(word)
96+
error_message = (f'Called remove_suffix_ness("{word}"). '
97+
f'The function returned "{actual_result}", '
98+
f'but the tests expected "{expected}" after the '
99+
'suffix was removed.')
100+
101+
self.assertEqual(actual_result, expected, msg=error_message)
74102

75103
@pytest.mark.task(taskno=4)
76104
def test_adjective_to_verb(self):
@@ -86,9 +114,13 @@ def test_adjective_to_verb(self):
86114
index_data = [-2, -1, 3, 3, -2, -3, 5, 2, 1]
87115
result_data = ['brighten', 'darken', 'harden', 'soften',
88116
'lighten', 'dampen', 'shorten', 'weaken', 'blacken']
89-
number_of_variants = range(1, len(input_data) + 1)
90117

91-
for variant, sentence, index, result in zip(number_of_variants, input_data, index_data, result_data):
92-
with self.subTest(f'variation #{variant}', sentence=sentence, index=index, result=result):
93-
self.assertEqual(adjective_to_verb(sentence, index), result,
94-
msg=f'Expected: {result} but got a different word instead.')
118+
for variant, (sentence, index, expected) in enumerate(zip(input_data, index_data, result_data), start=1):
119+
with self.subTest(f'variation #{variant}', sentence=sentence, index=index, expected=expected):
120+
actual_result = adjective_to_verb(sentence, index)
121+
error_message = (f'Called adjective_to_verb("{sentence}", {index}). '
122+
f'The function returned "{actual_result}", but the tests '
123+
f'expected "{expected}" as the verb for '
124+
f'the word at index {index}.')
125+
126+
self.assertEqual(actual_result, expected, msg=error_message)

0 commit comments

Comments
 (0)