Invalid file name: must contain only [a-z0-9_.]

本文深入解析了文件命名规范,强调了在指定目录(如res)下,文件名仅允许包含小写字母(a-z)、数字(0-9)、下划线(_)和小数点(.)。特别提醒读者避免使用大写字母以确保命名符合标准。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Invalid file name: must contain only [a-z0-9_.]  ---命名不正确

res下的文件命名不能有大写字母,换句话说它只支持小写的a到z、0到9、下划线“_”和小数点“.”

PS D:\a\b\PythonProject1> pytest ========================================================================= test session starts ========================================================================= platform win32 -- Python 3.11.9, pytest-8.4.1, pluggy-1.6.0 rootdir: D:\a\b\PythonProject1 configfile: pytest.ini testpaths: test_test/ plugins: html-4.1.1, metadata-3.1.1, parallel-0.1.1, repeat-0.9.4, testreport-1.1.6, xdist-3.8.0 collected 3 items test_test\test_api.py .FF [100%] ============================================================================== FAILURES =============================================================================== ________________________________________________________ TestLogin.test_login_module[api_info0-testcase0-2-3] _________________________________________________________ self = <test_test.test_api.TestLogin object at 0x0000014DF0970690> api_info = {&#39;api_name&#39;: &#39;用户登录&#39;, &#39;headers&#39;: {&#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded&#39;}, &#39;method&#39;: &#39;post&#39;, &#39;url&#39;: &#39;https://10.121.177.71/itf/session&#39;, ...} testcase = {&#39;data&#39;: {&#39;password&#39;: &#39;admin&#39;, &#39;username&#39;: &#39;admin&#39;}} @pytest.mark.passdef @pytest.mark.repeat(3) @pytest.mark.parametrize(&#39;api_info,testcase&#39;, YamlUtil().read_def_yaml(&#39;get_new.yaml&#39;)) def test_login_module(self, api_info, testcase): if &#39;case_name&#39; not in testcase: testcase[&#39;case_name&#39;] = f"默认用例_{id(testcase)}" # 用唯一标识避免重复 > RequestsBase().execute_test_cases(api_info, testcase) test_test\test_api.py:14: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ unit_tools\apiutils_single.py:121: in execute_test_cases raise e unit_tools\apiutils_single.py:117: in execute_test_cases self.asserts.assert_result(validation,response.json(),status_code) unit_tools\assertion_utils.py:125: in assert_result raise exceptions _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cls = <class &#39;unit_tools.assertion_utils.Assertions&#39;>, expected_result = None response = {&#39;CSRFToken&#39;: &#39;6d4IxqO2&#39;, &#39;ChangePasswordAlert&#39;: 0, &#39;CommConfigPriv&#39;: 1, &#39;DebugPriv&#39;: 1, ...}, status_code = 200 @classmethod def assert_result(cls, expected_result, response, status_code): """ 断言主函数,通过all_flag标记,如all_flag == 0表示测试成功,否则为失败 :param expected_result: (list)yaml文件validation关键词下面的预期结果 :param response: (dict)接口的实际响应信息 :param status_code: (int)接口的实际响应状态码 :return: """ all_flag = 0 # 通过字典映射方式管理不同的断言方式 assert_methods = { &#39;code&#39;: cls.status_code_assert, &#39;contain&#39;: cls.contain_assert, &#39;eq&#39;: cls.equal_assert # &#39;ne&#39;: cls.not_equal_assert, } try: > for yq in expected_result: E TypeError: &#39;NoneType&#39; object is not iterable unit_tools\assertion_utils.py:110: TypeError ------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------- 请求头参数: {&#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded&#39;} 参数类型:data 请求参数:{"username": "admin", "password": "admin"} 接口返回值: { "ResidueDay": 255, "ok": 0, "privilege": 4, "user_id": 2, "extendedpriv": 383, "racsession_id": 8, "remote_addr": "10.121.178.218", "server_name": "10.12 1.177.71", "server_addr": "10.121.177.71", "HTTPSEnabled": 1, "CSRFToken": "6d4IxqO2", "channel": 1, "passwordStatus": 0, "encrypt_flag": 0, "SelfSetPriv": 1, "InfoQuer yPriv": 1, "DebugPriv": 1, "PowerConPriv": 1, "SecuConPriv": 1, "RemoteMediaPriv": 1, "RemoteKVMPriv": 1, "CommConfigPriv": 1, "UserConfigPriv": 1, "group_name": "Administrator", "ChangePasswordAlert": 0 } 出现异常,--&#39;NoneType&#39; object is not iterable ________________________________________________________ TestLogin.test_login_module[api_info0-testcase0-3-3] _________________________________________________________ self = <test_test.test_api.TestLogin object at 0x0000014DF320E050> api_info = {&#39;api_name&#39;: &#39;用户登录&#39;, &#39;headers&#39;: {&#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded&#39;}, &#39;method&#39;: &#39;post&#39;, &#39;url&#39;: &#39;https://10.121.177.71/itf/session&#39;, ...} testcase = {&#39;data&#39;: {&#39;password&#39;: &#39;admin&#39;, &#39;username&#39;: &#39;admin&#39;}} @pytest.mark.passdef @pytest.mark.repeat(3) @pytest.mark.parametrize(&#39;api_info,testcase&#39;, YamlUtil().read_def_yaml(&#39;get_new.yaml&#39;)) def test_login_module(self, api_info, testcase): if &#39;case_name&#39; not in testcase: testcase[&#39;case_name&#39;] = f"默认用例_{id(testcase)}" # 用唯一标识避免重复 > RequestsBase().execute_test_cases(api_info, testcase) test_test\test_api.py:14: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ unit_tools\apiutils_single.py:121: in execute_test_cases raise e unit_tools\apiutils_single.py:117: in execute_test_cases self.asserts.assert_result(validation,response.json(),status_code) unit_tools\assertion_utils.py:125: in assert_result raise exceptions _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cls = <class &#39;unit_tools.assertion_utils.Assertions&#39;>, expected_result = None response = {&#39;CSRFToken&#39;: &#39;Su8wXUR2&#39;, &#39;ChangePasswordAlert&#39;: 0, &#39;CommConfigPriv&#39;: 1, &#39;DebugPriv&#39;: 1, ...}, status_code = 200 @classmethod def assert_result(cls, expected_result, response, status_code): """ 断言主函数,通过all_flag标记,如all_flag == 0表示测试成功,否则为失败 :param expected_result: (list)yaml文件validation关键词下面的预期结果 :param response: (dict)接口的实际响应信息 :param status_code: (int)接口的实际响应状态码 :return: """ all_flag = 0 # 通过字典映射方式管理不同的断言方式 assert_methods = { &#39;code&#39;: cls.status_code_assert, &#39;contain&#39;: cls.contain_assert, &#39;eq&#39;: cls.equal_assert # &#39;ne&#39;: cls.not_equal_assert, } try: > for yq in expected_result: E TypeError: &#39;NoneType&#39; object is not iterable unit_tools\assertion_utils.py:110: TypeError ------------------------------------------------------------------------ Captured stdout call ------------------------------------------------------------------------- 请求头参数: {&#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded&#39;} 参数类型:data 请求参数:{"username": "admin", "password": "admin"} 接口返回值: { "ResidueDay": 255, "ok": 0, "privilege": 4, "user_id": 2, "extendedpriv": 383, "racsession_id": 9, "remote_addr": "10.121.178.218", "server_name": "10.12 1.177.71", "server_addr": "10.121.177.71", "HTTPSEnabled": 1, "CSRFToken": "Su8wXUR2", "channel": 1, "passwordStatus": 0, "encrypt_flag": 0, "SelfSetPriv": 1, "InfoQuer yPriv": 1, "DebugPriv": 1, "PowerConPriv": 1, "SecuConPriv": 1, "RemoteMediaPriv": 1, "RemoteKVMPriv": 1, "CommConfigPriv": 1, "UserConfigPriv": 1, "group_name": "Administrator", "ChangePasswordAlert": 0 } 出现异常,--&#39;NoneType&#39; object is not iterable ========================================================================== warnings summary =========================================================================== test_test/test_api.py::TestLogin::test_login_module[api_info0-testcase0-1-3] test_test/test_api.py::TestLogin::test_login_module[api_info0-testcase0-2-3] test_test/test_api.py::TestLogin::test_login_module[api_info0-testcase0-3-3] D:\python\Lib\site-packages\urllib3\connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host &#39;10.121.177.71&#39;. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings warnings.warn( -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ======================================================================= short test summary info ======================================================================= FAILED test_test/test_api.py::TestLogin::test_login_module[api_info0-testcase0-2-3] - TypeError: &#39;NoneType&#39; object is not iterable FAILED test_test/test_api.py::TestLogin::test_login_module[api_info0-testcase0-3-3] - TypeError: &#39;NoneType&#39; object is not iterable
最新发布
08-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值