Skip to content

Commit 89db59b

Browse files
authored
[Meltdown Mitigation]: Modified Test Error Messages & Touched Up Docs (#3515)
* Modified test error messages to better match test runner changes. Also did touchup for links in docs. * Updated test error messages to be more verbose. * Revert "Updated test error messages to be more verbose." This reverts commit e800f4e. [no important files changed]
1 parent 538e2d9 commit 89db59b

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

exercises/concept/meltdown-mitigation/.docs/hints.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88

99
## 1. Check for criticality
1010

11-
- Comparison operators and boolean operations can be combined and used with conditionals.
11+
- Comparison operators ([comparisons][comparisons review]) and boolean operations ([concept:python/bools]()) can be combined and used with conditionals.
1212
- Conditional expressions must evaluate to `True` or `False`.
1313
- `else` can be used for a code block that will execute when all conditional tests return `False`.
1414

1515
```python
1616
>>> item = 'blue'
1717
>>> item_2 = 'green'
1818

19-
>>> if len(item) >=3 and len(item_2) < 5:
19+
>>> if len(item) >= 3 and len(item_2) < 5:
2020
print('Both pass the test!')
21-
elif len(item) >=3 or len(item_2) < 5:
21+
elif len(item) >= 3 or len(item_2) < 5:
2222
print('One passes the test!')
2323
else:
2424
print('None pass the test!')
@@ -29,20 +29,20 @@
2929
## 2. Determine the Power output range
3030

3131
- Comparison operators can be combined and used with conditionals.
32-
- Any number of `elif` statements can be used as "branches".
32+
- Any number of `elif` statements can be used as decision "branches".
3333
- Each "branch" can have a separate `return`
3434

3535
## 3. Fail Safe Mechanism
3636

3737
- Comparison operators can be combined and used with conditionals.
38-
- Any number of `elif` statements can be used as "branches".
38+
- Any number of `elif` statements can be used as decision "branches".
3939
- Each "branch" can have a separate `return`
4040

4141

42-
[python comparisons examples]: https://www.tutorialspoint.com/python/comparison_operators_example.htm
4342
[boolean operations]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not
43+
[comparisons review]: https://www.learnpython.dev/02-introduction-to-python/090-boolean-logic/20-comparisons/
4444
[comparisons]: https://docs.python.org/3/library/stdtypes.html#comparisons
45+
[control flow tools]: https://docs.python.org/3/tutorial/controlflow.html
4546
[python booleans]: https://realpython.com/python-boolean/
47+
[python comparisons examples]: https://www.tutorialspoint.com/python/comparison_operators_example.htm
4648
[real python conditionals]: https://realpython.com/python-conditional-statements/
47-
[control flow tools]: https://docs.python.org/3/tutorial/controlflow.html
48-

exercises/concept/meltdown-mitigation/.docs/introduction.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
In Python, [`if`][if statement], `elif` (_a contraction of 'else and if'_) and `else` statements are used to [control the flow][control flow tools] of execution and make decisions in a program.
44
Unlike many other programming languages, Python versions 3.9 and below do not offer a formal case-switch statement, instead using multiple `elif` statements to serve a similar purpose.
55

6-
Python 3.10 introduces a variant case-switch statement called `pattern matching`, which will be covered separately in another concept.
6+
Python 3.10 introduces a variant case-switch statement called `structural pattern matching`, which will be covered separately in another concept.
77

8-
Conditional statements use expressions that must resolve to `True` or `False` -- either by returning a `bool` directly, or by evaluating ["truthy" or "falsy"][truth value testing].
8+
Conditional statements use expressions that must resolve to `True` or `False` -- either by returning a `bool` type directly, or by evaluating as ["truthy" or "falsy"][truth value testing].
99

1010
```python
1111
x = 10
@@ -74,8 +74,8 @@ else:
7474
'13'
7575
```
7676

77-
[if statement]: https://docs.python.org/3/reference/compound_stmts.html#the-if-statement
78-
[control flow tools]: https://docs.python.org/3/tutorial/controlflow.html#more-control-flow-tools
79-
[truth value testing]: https://docs.python.org/3/library/stdtypes.html#truth-value-testing
8077
[boolean operations]: https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not
8178
[comparisons]: https://docs.python.org/3/library/stdtypes.html#comparisons
79+
[control flow tools]: https://docs.python.org/3/tutorial/controlflow.html#more-control-flow-tools
80+
[if statement]: https://docs.python.org/3/reference/compound_stmts.html#the-if-statement
81+
[truth value testing]: https://docs.python.org/3/library/stdtypes.html#truth-value-testing

exercises/concept/meltdown-mitigation/.meta/design.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
## Goal
55

6-
The goal of this exercise is to teach the student what is a `conditional` and how they are used in Python.
6+
The goal of this exercise is to teach the student about `conditionals` and how they are used in Python.
77

88
## Learning objectives
99

10-
- learn some general things about `control flow` in python
10+
- learn some general things about `control flow` in Python
1111
- create a `conditional` structure to choose something, take a decision
1212
- use an `if...else` structure
1313
- use an `if..elif...else` structure

exercises/concept/meltdown-mitigation/conditionals_test.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ def test_is_criticality_balanced(self):
3030

3131
# pylint: disable=assignment-from-no-return
3232
actual_result = is_criticality_balanced(temp, neutrons_emitted)
33-
failure_message = (f'Expected {expected} but returned {actual_result} '
34-
f'with T={temp} and neutrons={neutrons_emitted}')
33+
failure_message = (f'Called is_criticality_balanced({temp}, {neutrons_emitted}). '
34+
f' The function returned {actual_result}, '
35+
f'but the test expected {expected} as the return value.')
36+
3537
self.assertEqual(actual_result, expected, failure_message)
3638

3739
@pytest.mark.task(taskno=2)
@@ -52,8 +54,10 @@ def test_reactor_efficiency(self):
5254

5355
# pylint: disable=assignment-from-no-return
5456
actual_result = reactor_efficiency(voltage, current, theoretical_max_power)
55-
failure_message = (f'Expected {expected} but returned {actual_result} '
56-
f'with voltage={voltage}, current={current}, max_pow={theoretical_max_power}')
57+
failure_message =(f'Called reactor_efficiency({voltage}, {current}, {theoretical_max_power}). '
58+
f'The function returned {actual_result}, '
59+
f'but the test expected {expected} as the return value.')
60+
5761
self.assertEqual(actual_result, expected, failure_message)
5862

5963
@pytest.mark.task(taskno=3)
@@ -71,6 +75,8 @@ def test_fail_safe(self):
7175

7276
# pylint: disable=assignment-from-no-return
7377
actual_result = fail_safe(temp, neutrons_per_second, threshold)
74-
failure_message = (f'Expected {expected} but returned {actual_result} with T={temp}, '
75-
f'neutrons={neutrons_per_second}, threshold={threshold}')
78+
failure_message = (f'Called fail_safe({temp}, {neutrons_per_second}, {threshold}). '
79+
f'The function returned {actual_result}, '
80+
f'but the test expected {expected} as the return value.')
81+
7682
self.assertEqual(actual_result, expected, failure_message)

0 commit comments

Comments
 (0)