1. 程式人生 > >4. Selenium2 自動化測試實戰-基於Python語言-跨目錄模組呼叫

4. Selenium2 自動化測試實戰-基於Python語言-跨目錄模組呼叫

projec/

|___model/

|      |___count.py

|      |___new_count.py

|___test.py

count.py

class A():
    def add(self,a,b):
        return a +b

new_count.py
from count import A
class B (A):
    def sub(self,a,b):
        return a-b
    
result =B().add(2,5)
print(result)

test.py

import sys
sys.path .append ("./model") #將model命令新增到系統環境變數下
from model import new_count

test =new_count.B()
test.add(2,4)


輸出結果:

=================================

7