-テスト中にデータベースを(外部から)見ることは可能ですか?私は、テストを書くことをしようとしている
from django.test import TestCase
from django.test.client import Client
class MyTests(TestCase):
def _create_person_object(self):
person = Person(email='[email protected]', password='test')
person.save()
return
def _login():
self.client.post('/login/', {'email': '[email protected]', 'password' : 'test'})
return
def setUp(self):
self.client = Client()
def test_login(self):
self._create_person_object()
self._login()
input('wait and enter')
# person = Person.object.get(email ='[email protected]')
# self.assertEqual(person.password, 'test') #
response = self.client.get('/denied_area/')
self.assertEqual(response.status_code, 200)
UPDATE 私は取引を忘れ、それはテスト中にデータベースを調べることは不可能であるということになります。私は正しい?
私はそうだと思いますが、それを削除します。あなたの問題は、person.passwordがハッシュされているということです。https://docs.djangoproject.com/es/1.10/topics/auth/passwords/ –
あなたは正しいかもしれませんが、パスワードテストでObject Personを作成し、それをチェックしようとしました同じパスワード。だから私はテーブルの中に何が入っているのかを知りたいのですが、なぜ入力を入れたのですか?(待ちと入力) –
パスワード 'test'で作成した後、パスワードがハッシュされずにdjango freaks dbからすべてを削除し、手動で移動して空のdbを表示します。私はそれが起こっていると思う。セ・ダニエル・ローズマンの答え。 –