Skip to content

Commit b966f79

Browse files
authored
Changed test error messages to sync with the runner changes. Other Msc. typo and language edits. (#3527)
[no important files changed]
1 parent 3445ffd commit b966f79

File tree

5 files changed

+63
-30
lines changed

5 files changed

+63
-30
lines changed

concepts/basics/about.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Imperative, declarative (e.g., functional), and object-oriented programming _sty
66

77
Python puts a strong emphasis on code readability and (_similar to Haskell_) uses [significant indentation][significant indentation] to denote function, method, and class definitions.
88

9-
Python was created by Guido van Rossum and first released in 1991. The [Python Software Foundation][psf] manages and directs resources for Python and CPython development and receives proposals for changes to the language from [members][psf membership] of the community via [Python Enhancement Proposals or PEPs][peps].
9+
Python was created by Guido van Rossum and first released in 1991.
10+
The [Python Software Foundation][psf] manages and directs resources for Python and CPython development and receives proposals for changes to the language from [members][psf membership] of the community via [Python Enhancement Proposals or PEPs][peps].
1011

1112

1213
Complete documentation for the current release can be found at [docs.python.org][python docs].
@@ -18,8 +19,14 @@ Complete documentation for the current release can be found at [docs.python.org]
1819
- [Python FAQs][python faqs]
1920
- [Python Glossary of Terms][python glossary of terms]
2021

22+
<br>
23+
24+
This first concept introduces 4 major Python language features:
25+
1. Name Assignment (_variables and constants_),
26+
2. Functions (_the `def` keyword and the `return` keyword_),
27+
3. Comments, and
28+
4. Docstrings.
2129

22-
This concept introduces 4 major Python language features: Name Assignment (_variables and constants_), Functions (_and the return keyword_), Comments, and Docstrings.
2330

2431

2532
~~~~exercism/note
@@ -32,9 +39,9 @@ On the Python track, [variables][variables] are always written in [`snake_case`]
3239
3340
3441
[snake case]: https://en.wikipedia.org/wiki/Snake_case
42+
[the zen of python]: https://www.python.org/dev/peps/pep-0020/
3543
[variables]: https://realpython.com/python-variables/
3644
[what is pythonic]: https://blog.startifact.com/posts/older/what-is-pythonic.html
37-
[the zen of python]: https://www.python.org/dev/peps/pep-0020/
3845
~~~~
3946

4047

@@ -127,8 +134,8 @@ def add_two_numbers(number_one, number_two):
127134
IndentationError: unindent does not match any outer indentation level
128135
```
129136

130-
Functions explicitly return a value or object via the [`return`][return] keyword.
131-
Functions that do not have an explicit `return` expression will _implicitly_ return [`None`][none].
137+
Functions _explicitly_ return a value or object via the [`return`][return] keyword.
138+
Functions that do not have an _explicit_ `return` expression will _implicitly_ return [`None`][none].
132139

133140
```python
134141
# Function definition on first line.

concepts/basics/links.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[
2-
{"url": "https://lerner.co.il/2019/06/18/understanding-python-assignment/",
2+
{
3+
"url": "https://lerner.co.il/2019/06/18/understanding-python-assignment/",
34
"description": "Reuven Lerner: Understanding Python Assignment"
45
},
56
{
@@ -14,6 +15,10 @@
1415
"url": "https://www.pythonmorsels.com/everything-is-an-object/",
1516
"description": "Python Morsels: Everything is an Object"
1617
},
18+
{
19+
"url": "https://eli.thegreenplace.net/2012/03/23/python-internals-how-callables-work/",
20+
"description": "Eli Bendersky: Python internals: how callables work"
21+
},
1722
{
1823
"url": "https://stackoverflow.com/questions/11328920/is-python-strongly-typed",
1924
"description": "dynamic typing and strong typing"

exercises/concept/guidos-gorgeous-lasagna/.docs/hints.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
## General
44

55
- [The Python Tutorial][the python tutorial] can be a great introduction.
6-
- [Numbers][numbers] in Python can be integers, floats, or complex.
76
- [PEP 8][pep8] is the Python code style guide.
7+
- [PEP 257][PEP257] details Python docstring conventions.
8+
- [Numbers][numbers] in Python can be integers, floats, or complex.
9+
810

911
## 1. Define expected bake time in minutes
1012

11-
- You need to [name][naming] a constant, and [assign][assignment] it an integer value.
13+
- You need to [name][naming] a constant, and [assign][assignment] it an [integer][numbers] value.
1214

1315
## 2. Calculate remaining bake time in minutes
1416

@@ -25,7 +27,7 @@
2527

2628
## 4. Calculate total elapsed cooking time (prep + bake) in minutes
2729

28-
- You need to define a [function][defining-functions] with two parameters.
30+
- You need to define a [function][defining functions] with two parameters.
2931
- Remember: you can always _call_ a function you've defined previously.
3032
- You can use the [mathematical operator for addition][python as a calculator] to sum values.
3133
- This function should [return a value][return].

exercises/concept/guidos-gorgeous-lasagna/.docs/introduction.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@ This includes numbers, strings, lists, and even functions.
88

99
We'll dig more into what all of that means as we continue through the track.
1010

11-
This first exercise introduces 4 major Python language features: Name Assignment (_variables and constants_), Functions (_and the return keyword_), Comments, and Docstrings.
11+
This first exercise introduces 4 major Python language features:
12+
1. Name Assignment (_variables and constants_),
13+
2. Functions (_the `def` keyword and the `return` keyword_),
14+
3. Comments, and
15+
4. Docstrings.
1216

1317

1418
~~~~exercism/note
1519
1620
In general, content, tests, and analyzer tooling for the Python track follow the style conventions outlined in [PEP 8](https://www.python.org/dev/peps/pep-0008/) and [PEP 257](https://www.python.org/dev/peps/pep-0257/) for Python code style, with the additional (strong) suggestion that there be no single letter variable names.
1721
18-
On the Python track, [variables][variables] are always written in [`snake_case`][snake case], and constants in `SCREAMING_SNAKE_CASE`
22+
On the Python track, [variables][variables] are always written in [`snake_case`][snake case], and constants in `SCREAMING_SNAKE_CASE`.
1923
2024
[variables]: https://realpython.com/python-variables/
2125
[snake case]: https://en.wikipedia.org/wiki/Snake_case
@@ -84,7 +88,7 @@ IndentationError: unindent does not match any outer indentation level
8488
```
8589

8690
Functions explicitly return a value or object via the [`return`][return] keyword.
87-
Functions that do not have an explicit `return` expression will _implicitly_ return [`None`][none].
91+
Functions that do not have an _explicit_ `return` expression will _implicitly_ return [`None`][none].
8892

8993
```python
9094
# Function definition on first line.
@@ -201,7 +205,6 @@ Raise a number to an arbitrary power.
201205
Takes number_one and raises it to the power of number_two, returning the result.
202206
```
203207

204-
[pep257]: https://www.python.org/dev/peps/pep-0257/
205208
[calls]: https://docs.python.org/3/reference/expressions.html#calls
206209
[comments]: https://realpython.com/python-comments-guide/#python-commenting-basics
207210
[docstring]: https://docs.python.org/3/tutorial/controlflow.html#tut-docstrings
@@ -215,5 +218,6 @@ Raise a number to an arbitrary power.
215218
[module]: https://docs.python.org/3/tutorial/modules.html
216219
[none]: https://docs.python.org/3/library/constants.html
217220
[parameters]: https://docs.python.org/3/glossary.html#term-parameter
221+
[pep257]: https://www.python.org/dev/peps/pep-0257/
218222
[return]: https://docs.python.org/3/reference/simple_stmts.html#return
219223
[type hints]: https://docs.python.org/3/library/typing.html

exercises/concept/guidos-gorgeous-lasagna/lasagna_test.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,45 @@ def test_EXPECTED_BAKE_TIME(self):
3737
@pytest.mark.task(taskno=2)
3838
def test_bake_time_remaining(self):
3939
input_data = [1, 2, 5, 10, 15, 23, 33, 39]
40-
result_data = [40 - item for item in input_data]
40+
result_data = [39, 38, 35, 30, 25, 17, 7, 1]
4141

42-
for variant, (time, result) in enumerate(zip(input_data, result_data), start=1):
43-
with self.subTest(f'variation #{variant}', time=time, result=result):
44-
failure_msg = f'Expected: {result} but the bake time remaining was calculated incorrectly.'
45-
self.assertEqual(bake_time_remaining(time), result, msg=failure_msg)
42+
for variant, (time, expected) in enumerate(zip(input_data, result_data), start=1):
43+
with self.subTest(f'variation #{variant}', time=time, expected=expected):
44+
actual_result = bake_time_remaining(time)
45+
failure_msg = (f'Called bake_time_remaining({time}). '
46+
f'The function returned {actual_result}, but the tests '
47+
f'expected {expected} as the remaining bake time.')
48+
49+
self.assertEqual(actual_result, expected, msg=failure_msg)
4650

4751
@pytest.mark.task(taskno=3)
4852
def test_preparation_time_in_minutes(self):
4953
input_data = [1, 2, 5, 8, 11, 15]
50-
result_data = [item * 2 for item in input_data]
54+
result_data = [2, 4, 10, 16, 22, 30]
55+
56+
for variant, (layers, expected) in enumerate(zip(input_data, result_data), start=1):
57+
with self.subTest(f'variation #{variant}', layers=layers, expected=expected):
58+
actual_result = preparation_time_in_minutes(layers)
59+
failure_msg = (f'Called preparation_time_in_minutes({layers}). '
60+
f'The function returned {actual_result}, but the tests '
61+
f'expected {expected} as the preparation time.')
5162

52-
for variant, (layers, time) in enumerate(zip(input_data, result_data), start=1):
53-
with self.subTest(f'variation #{variant}', layers=layers, time=time):
54-
failure_msg = f'Expected: {time} minutes, but preparation time was calculated incorrectly.'
55-
self.assertEqual(preparation_time_in_minutes(layers), time, msg=failure_msg)
63+
self.assertEqual(actual_result, expected, msg=failure_msg)
5664

5765
@pytest.mark.task(taskno=4)
5866
def test_elapsed_time_in_minutes(self):
5967
layer_data = (1, 2, 5, 8, 11, 15)
6068
time_data = (3, 7, 8, 4, 15, 20)
61-
result_data = [prep * 2 + elapsed for prep, elapsed in zip(layer_data, time_data)]
69+
result_data = [5, 11, 18, 20, 37, 50]
6270

63-
for variant, (layers, time, total_time) in enumerate(zip(layer_data, time_data, result_data), start=1):
64-
with self.subTest(f'variation #{variant}', layers=layers, time=time, total_time=total_time):
65-
failure_msg = f'Expected {time} minutes elapsed, but the timing was calculated incorrectly.'
66-
self.assertEqual(elapsed_time_in_minutes(layers, time), total_time, msg=failure_msg)
71+
for variant, (layers, time, expected) in enumerate(zip(layer_data, time_data, result_data), start=1):
72+
with self.subTest(f'variation #{variant}', layers=layers, time=time, expected=expected):
73+
actual_result = elapsed_time_in_minutes(layers, time)
74+
failure_msg = (f'Called elapsed_time_in_minutes({layers}, {time}). '
75+
f'The function returned {actual_result}, but the tests '
76+
f'expected {expected} as the elapsed time.')
77+
78+
self.assertEqual(actual_result, expected, msg=failure_msg)
6779

6880
@pytest.mark.task(taskno=5)
6981
def test_docstrings_were_written(self):
@@ -77,6 +89,9 @@ def test_docstrings_were_written(self):
7789

7890
for variant, function in enumerate(functions, start=1):
7991
with self.subTest(f'variation #{variant}', function=function):
80-
failure_msg = f'Expected a docstring for `{function.__name__}`, but received `None` instead.'
92+
actual_result = function.__doc__
93+
failure_msg = (f'Called {function.__name__}.__doc__. {actual_result} was returned, '
94+
f'but the tests expected a docstring for the {function.__name__} function.')
95+
8196
# Check that the __doc__ key is populated for the function.
82-
self.assertIsNotNone(function.__doc__, msg=failure_msg)
97+
self.assertIsNotNone(actual_result, msg=failure_msg)

0 commit comments

Comments
 (0)