1、说明:自动化项目中,测试某个业务流程,流程节点(交易节点)之间往往存在数据的传递,即某个交易节点的案例执行需要其上一个案例中使用过的数据的或案例执行产生的数据。在不使用测试框架的情况下,可以通过Python在两个.py文件之间传递变量实现。
2、Python文件1:study_01.py
# 测试数据
class study01:
id = 'study01'
name1 = '张三' + id
name2 = '里斯' + id
3、Python文件2:study_02.py
from study_01 import study01
class study02:
print('study02 id is :' + study01.id)
print('study02 name1 is :' + study01.name1)
print('study02 name2 is :' + study01.name2)
运行结果:
study02 id is :study01
study02 name1 is :张三study01
study02 name2 is :里斯study01
4、Python文件3:study_03.py
from study_01 import study01
class study03:
print('study03 id is :' + study01.id)
print('study03 name1 is :' + study01.name1)
print('study03 name2 is :' + study01.name2)
运行结果:
study03 id is :study01
study03 name1 is :张三study01
study03 name2 is :里斯study01