[問題] pytest多層呼叫時,missing 1 required p
在pytest中,自定義的傳入參數想在其他python檔案使用,需要將conftest.py中接收參數的method name當作參數傳入,如程式碼中的common_method(self, test_var)
但如果common_method又會被其他python檔案中的function呼叫,該怎麼處理第一個參數呢?
EX: test_demo.py檔案中想要使用CommonModule().common_method(),會需要傳入參數test_var,但common_method中的test_var是為了接收自訂傳入參數
在類似這樣兩層呼叫的方式下,怎麼使用接收進來的參數,才能解決 TypeError: common_module() missing 1 required positional argument: 'test_var'
附上程式碼圖檔,先感謝各位高手大大
https://i.imgur.com/aqymMDO.jpg
-----
Sent from JPTT on my iPhone
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.83.131.117 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1616136435.A.E7B.html
→
03/19 20:21,
3年前
, 1F
03/19 20:21, 1F
→
03/19 20:42,
3年前
, 2F
03/19 20:42, 2F
→
03/19 20:42,
3年前
, 3F
03/19 20:42, 3F
→
03/19 20:42,
3年前
, 4F
03/19 20:42, 4F
→
03/19 20:42,
3年前
, 5F
03/19 20:42, 5F
→
03/21 17:52,
3年前
, 6F
03/21 17:52, 6F
→
03/21 22:23,
3年前
, 7F
03/21 22:23, 7F
→
03/21 22:23,
3年前
, 8F
03/21 22:23, 8F
→
03/21 22:23,
3年前
, 9F
03/21 22:23, 9F
→
03/21 22:23,
3年前
, 10F
03/21 22:23, 10F
→
03/21 22:31,
3年前
, 11F
03/21 22:31, 11F
→
03/21 22:31,
3年前
, 12F
03/21 22:31, 12F
→
03/21 22:31,
3年前
, 13F
03/21 22:31, 13F
→
03/22 19:03,
3年前
, 14F
03/22 19:03, 14F
→
03/22 19:03,
3年前
, 15F
03/22 19:03, 15F
→
03/22 19:03,
3年前
, 16F
03/22 19:03, 16F
→
03/22 19:03,
3年前
, 17F
03/22 19:03, 17F
→
03/22 19:03,
3年前
, 18F
03/22 19:03, 18F
→
03/22 19:29,
3年前
, 19F
03/22 19:29, 19F
→
03/22 19:29,
3年前
, 20F
03/22 19:29, 20F
→
03/22 19:29,
3年前
, 21F
03/22 19:29, 21F
→
03/22 19:29,
3年前
, 22F
03/22 19:29, 22F
→
03/22 19:29,
3年前
, 23F
03/22 19:29, 23F
→
03/22 19:29,
3年前
, 24F
03/22 19:29, 24F
→
03/22 19:29,
3年前
, 25F
03/22 19:29, 25F
→
03/22 19:29,
3年前
, 26F
03/22 19:29, 26F
→
03/22 19:29,
3年前
, 27F
03/22 19:29, 27F
Python 近期熱門文章
PTT數位生活區 即時熱門文章