2016-07-15 32 views
0

我對Python和Behave很新。在我的步文件,test_steps.py,我已經導入了以下內容:如何在python中只導入一次模塊行爲步驟文件

from behave import given, when, then, step 
from behave_http.steps import * 
from datetime import datetime 
import time 
import pdb 
import xmltodict 
import requests 

如果我創造了另一個步文件,test2_steps.py,我不得不再次導入以上。 有沒有辦法避免這種情況?

謝謝你的幫助!

+0

不行,你必須輸入你想在一個文件中使用任何東西。 –

回答

0

知道給定文件的所有輸入通常很有用;但是,你可以這樣做以下:

config.py

from behave import given, when, then, step 
from behave_http.steps import * 
from datetime import datetime 
import time 
import pdb 
import xmltodict 
import requests 

test2_steps.py

from config import * 
#other code here 
相關問題