當(dāng)我嘗試并行運(yùn)行測(cè)試時(shí),會(huì)出現(xiàn)多個(gè)問(wèn)題。根據(jù)文檔,“test_”被附加到數(shù)據(jù)庫(kù)中指定的數(shù)據(jù)庫(kù)名稱(chēng)之前。我使用了名稱(chēng)“postgres”,因此在運(yùn)行測(cè)試時(shí)創(chuàng)建的數(shù)據(jù)庫(kù)稱(chēng)為test_postgres。并行運(yùn)行測(cè)試時(shí),將創(chuàng)建以下數(shù)據(jù)庫(kù)(這是預(yù)期的):test_postgres_1、test_postgres_2、test_postgres_3和test_postgres_4。但是,使用該選項(xiàng)運(yùn)行所有測(cè)試時(shí),每個(gè)測(cè)試都會(huì)失敗,并顯示以下消息:其中 x 可以是 1、2、3 或 4。我可以看到已經(jīng)創(chuàng)建了以下數(shù)據(jù)庫(kù):其中x可以是1,2,3或4?!皃ostgres_x”從何而來(lái)?為什么“test_”沒(méi)有附加到這些前面?--parallel=4django.db.utils.OperationalError: FATAL: database "postgres_x" does not existtest_postgres_x此外,如果我手動(dòng)創(chuàng)建預(yù)期的數(shù)據(jù)庫(kù)(x = 1 到 4),則應(yīng)用于“主”數(shù)據(jù)庫(kù)的遷移不會(huì)應(yīng)用于克隆。這會(huì)導(dǎo)致類(lèi)似如下的錯(cuò)誤:.使用 4 個(gè)內(nèi)核時(shí),大約 1/4 的測(cè)試通過(guò)。postgres_xdjango.db.utils.ProgrammingError: relation "users_user" does not exist最后,如果我嘗試使用 遷移,我會(huì)得到:。postgres_xmigrate --database=postgres_xdjango.db.utils.ConnectionDoesNotExist: The connection postgres_x doesn't exist我確保所有測(cè)試都是隔離的,這樣我就可以并行運(yùn)行它們。我該怎么辦?
并行運(yùn)行測(cè)試時(shí)的錯(cuò)誤
炎炎設(shè)計(jì)
2022-08-02 16:18:58