我正在尝试访问固定装置内的属性,如何访问它。
竞赛.py
@pytest.fixture(scope="session")
def numbers():
one = 1
two = 2
total = one+two
return total
num.py
def test(numbers):
print("total = ",numbers.one)
上面出现以下错误
AttributeError: 'int' object has no attribute 'one'
如果我打印“数字”,我得到的答案是 3,但是如何访问固定功能内的变量。
def test(numbers):
print(numbers())
刚刚在函数内部声明的变量在函数外部不可访问。