Kredo Blog 最小再現コード教材｜実行確認済みの結果

> python3 broken.py
['朝のメモ']
['朝のメモ', '夜のメモ']

> python3 candidate_truthy.py
返された値: ['共有メモ']
渡したリスト: []
同じリスト: False

> python3 fixed.py
['朝のメモ']
['夜のメモ']

> python3 check_notes.py broken
test_01_first_call (__main__.NotesContract.test_01_first_call) ... ok
test_02_second_call_is_independent (__main__.NotesContract.test_02_second_call_is_independent) ... FAIL
test_03_first_result_stays_unchanged (__main__.NotesContract.test_03_first_result_stays_unchanged) ... FAIL
test_04_provided_empty_list_is_used (__main__.NotesContract.test_04_provided_empty_list_is_used) ... ok
test_05_provided_list_keeps_existing_note (__main__.NotesContract.test_05_provided_list_keeps_existing_note) ... ok
test_06_explicit_none_creates_new_list (__main__.NotesContract.test_06_explicit_none_creates_new_list) ... ERROR

======================================================================
ERROR: test_06_explicit_none_creates_new_list (__main__.NotesContract.test_06_explicit_none_creates_new_list)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/folders/42/20vk1l7s4v3frbmgzwstphf40000gn/T/kredo-mre-1eweg5s2/check_notes.py", line 44, in test_06_explicit_none_creates_new_list
    first = self.add_note("朝のメモ", None)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/var/folders/42/20vk1l7s4v3frbmgzwstphf40000gn/T/kredo-mre-1eweg5s2/broken.py", line 2, in add_note
    notes.append(label)
    ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'append'

======================================================================
FAIL: test_02_second_call_is_independent (__main__.NotesContract.test_02_second_call_is_independent)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/folders/42/20vk1l7s4v3frbmgzwstphf40000gn/T/kredo-mre-1eweg5s2/check_notes.py", line 24, in test_02_second_call_is_independent
    self.assertEqual(self.add_note("夜のメモ"), ["夜のメモ"])
AssertionError: Lists differ: ['朝のメモ', '夜のメモ'] != ['夜のメモ']

First differing element 0:
'朝のメモ'
'夜のメモ'

First list contains 1 additional elements.
First extra element 1:
'夜のメモ'

- ['朝のメモ', '夜のメモ']
+ ['夜のメモ']

======================================================================
FAIL: test_03_first_result_stays_unchanged (__main__.NotesContract.test_03_first_result_stays_unchanged)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/folders/42/20vk1l7s4v3frbmgzwstphf40000gn/T/kredo-mre-1eweg5s2/check_notes.py", line 29, in test_03_first_result_stays_unchanged
    self.assertEqual(first, ["朝のメモ"])
AssertionError: Lists differ: ['朝のメモ', '夜のメモ'] != ['朝のメモ']

First list contains 1 additional elements.
First extra element 1:
'夜のメモ'

- ['朝のメモ', '夜のメモ']
+ ['朝のメモ']

----------------------------------------------------------------------
Ran 6 tests in 0.001s

FAILED (failures=2, errors=1)

> python3 check_notes.py candidate_truthy
test_01_first_call (__main__.NotesContract.test_01_first_call) ... ok
test_02_second_call_is_independent (__main__.NotesContract.test_02_second_call_is_independent) ... ok
test_03_first_result_stays_unchanged (__main__.NotesContract.test_03_first_result_stays_unchanged) ... ok
test_04_provided_empty_list_is_used (__main__.NotesContract.test_04_provided_empty_list_is_used) ... FAIL
test_05_provided_list_keeps_existing_note (__main__.NotesContract.test_05_provided_list_keeps_existing_note) ... ok
test_06_explicit_none_creates_new_list (__main__.NotesContract.test_06_explicit_none_creates_new_list) ... ok

======================================================================
FAIL: test_04_provided_empty_list_is_used (__main__.NotesContract.test_04_provided_empty_list_is_used)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/folders/42/20vk1l7s4v3frbmgzwstphf40000gn/T/kredo-mre-1eweg5s2/check_notes.py", line 34, in test_04_provided_empty_list_is_used
    self.assertIs(result, provided)
AssertionError: ['共有メモ'] is not []

----------------------------------------------------------------------
Ran 6 tests in 0.001s

FAILED (failures=1)

> python3 check_notes.py fixed
test_01_first_call (__main__.NotesContract.test_01_first_call) ... ok
test_02_second_call_is_independent (__main__.NotesContract.test_02_second_call_is_independent) ... ok
test_03_first_result_stays_unchanged (__main__.NotesContract.test_03_first_result_stays_unchanged) ... ok
test_04_provided_empty_list_is_used (__main__.NotesContract.test_04_provided_empty_list_is_used) ... ok
test_05_provided_list_keeps_existing_note (__main__.NotesContract.test_05_provided_list_keeps_existing_note) ... ok
test_06_explicit_none_creates_new_list (__main__.NotesContract.test_06_explicit_none_creates_new_list) ... ok

----------------------------------------------------------------------
Ran 6 tests in 0.000s

OK

