Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 一次运行所有项目测试,但也能够独立运行它们(同时必须提供输入数据路径)_Python_Python 3.x_Unit Testing_Testing_Python Unittest - Fatal编程技术网

Python 一次运行所有项目测试,但也能够独立运行它们(同时必须提供输入数据路径)

Python 一次运行所有项目测试,但也能够独立运行它们(同时必须提供输入数据路径),python,python-3.x,unit-testing,testing,python-unittest,Python,Python 3.x,Unit Testing,Testing,Python Unittest,我的测试有以下文件夹结构: python-tests tests-folder-1 input-data <files_with_input_data_for_tests_from_this_folder> test_1.py test_2.py tests-folder-2 input-data

我的测试有以下文件夹结构:

    python-tests
        tests-folder-1
            input-data
                <files_with_input_data_for_tests_from_this_folder>
            test_1.py
            test_2.py
        tests-folder-2
            input-data
                <files_with_input_data_for_tests_from_this_folder>
            test_something_else_1.py
            test_something_else_2.py
        run.py

如果可能的话,我希望避免修改系统路径。

在test\u sth.py中,使用这个来获取测试数据

path = os.path.dirname(__file__)
TESTDATA = os.path.join(path, 'input-data/files_with_input_data_for_tests_from_this_folder.data')

昨天我在重读这个问题时发现了这一点,但是谢谢你的回答。也许是最简单的解决办法。
path = os.path.dirname(__file__)
TESTDATA = os.path.join(path, 'input-data/files_with_input_data_for_tests_from_this_folder.data')