3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[Django]DjangoのテストをDEBUG=Trueで実行する

Posted at
from django.conf import settings

if not settings.DEBUG:
    raise ...

# テストしたい処理

デバッグ用の機能をテストしたいと思っていて試してたんだけど、どう頑張っても例外になってしまう。
そこで、よくよく調べると「Djangoのテストは、settings.pyの内容に関わらずDEBUG=Falseとして実行される」ということが判明した。

「開発環境ではDEBUG=Trueテストしたいのになー」と思って調べてたら、Django1.11から--debug-modeオプションが追加されたらしい。

python3 manage.py --debug-mode
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?