클린 코드를 위한 테스트 주도 개발 3

2016-09-22

p.85

    결론부터 말하자면 여기는 책 잘못이 없고 내가 잘못 한 것이다. 이 책을 쭉 보면서 에러문구가 다르면 또 브라우저 문제일거라고 생각하고 그냥 쭉 진행을 해버렸다. 나처럼 이렇게 하면 안되고 TDD의 목적에 맞지도 않다. 결국 어디가 잘못인지 짐작이 안가서 에러를 해결 못했고 책을 처음부터 다시 읽으면서 따라하고있다. python functional_test.py를 실행하면 책에 나와있는 대로 AssertionError가 나오지 않았다.

    책에서 말하는 테스트 문구는 아래와 같다.
AssertionError: '2: 공작깃털을 이용해서 그물 만들기' not found in ['1: 공작깃털 사기', '1: 공작깃털을 이용해서 그물 만들기']
    내가 한 기능테스트의 에러문구는 아래와 같다.
AssertionError: '1: 공작깃털 사기' not found in []

    이 페이지의 아래에 있는 주석대로라면 서버를 재실행하면 해결이 된다. 하지만 해결이 되지않았다. p.67 아래에서 제안하는 name="item_text"라는 속성을 지정하지 않아서 생긴 문제도 아니다. 혹시나 브라우저 문제일까 싶었지만 크롬으로 해도 마찬가지였다. 터미널을 쭉 위로 올려보다가 migrate한 결과값이 책과 약간 다르게 나온것을 발견했다. 하지만 이는 AssertionError와 무관하다.

(venv-3.5.2) choehyeseonui-MacBook-Pro:superlists hsun$ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, lists, sessions
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying lists.0001_initial... OK
  Applying lists.0002_item_text... OK
  Applying sessions.0001_initial... OK

    바보같이 내가 한 실수는 이렇다.

  1. lists/views.py의 마지막줄은 return render(request, 'home.html', {'items': items}) 이며 {'items': items}를 빼먹었다.
  2. 졸린채로 해서 그런가 파일 저장을 잘못해서 이전의 코드와 지금의 코드가 꼬였다;; 역시 잠은 자면서 해야된다. 깃헙 repo를 새로 파서 다시 올려야 겠다.