目录结构
import pytestdef test_01():# 同级文件with open('1.txt', 'r', encoding='utf-8') as file:content = file.read()print(content)def test_02():# 同级目录的下的文件with open(r'upfile/2.txt', 'r', encoding='utf-8') as file:content = file.read()print(content)def test_03():# 上一级的文件with open(r'../3.txt', 'r', encoding='utf-8') as file:content = file.read()print(content)def test_04():# 上上一级的文件with open(r'../../4.txt', 'r', encoding='utf-8') as file:content = file.read()print(content)def test_05():# 同级目录下的目录下的文件with open(r'upfile/up/5.txt', 'r', encoding='utf-8') as file:content = file.read()print(content)if __name__ == '__main__':pytest.main('-s -v test_case_wenj_1.py')pass