4. Selenium2 自动化测试实战-基于Python语言-跨目录模块调用

时间:2022-03-24 07:33:41

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