diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 25adb293..d07d72e0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,7 +4,7 @@ **Fixed** -- fix: compatibility with testcase file path includes dots and space +- fix: compatibility with testcase file path includes dots, space and minus sign - fix: testcase generator, validate content.xxx => body.xxx - fix: scaffold for v3 diff --git a/httprunner/ext/make/__init__.py b/httprunner/ext/make/__init__.py index 4f073b38..7da40807 100644 --- a/httprunner/ext/make/__init__.py +++ b/httprunner/ext/make/__init__.py @@ -41,7 +41,7 @@ def convert_testcase_path(testcase_path: Text) -> Tuple[Text, Text]: if file_suffix not in [".json", ".yml", ".yaml"]: raise exceptions.ParamsError("") - file_name = raw_file_name.replace(" ", "_").replace(".", "_") + file_name = raw_file_name.replace(" ", "_").replace(".", "_").replace("-", "_") testcase_dir = os.path.dirname(testcase_path) testcase_python_path = os.path.join(testcase_dir, f"{file_name}_test.py") diff --git a/httprunner/ext/make/make_test.py b/httprunner/ext/make/make_test.py index 0b6dac26..44e309a6 100644 --- a/httprunner/ext/make/make_test.py +++ b/httprunner/ext/make/make_test.py @@ -24,10 +24,6 @@ class TestLoader(unittest.TestCase): convert_testcase_path("mubu.login.yml")[0], "mubu_login_test.py" ) - self.assertEqual( - convert_testcase_path("mubu login.yml")[0], - "mubu_login_test.py" - ) self.assertEqual( convert_testcase_path("/path/to/mubu.login.yml")[0], "/path/to/mubu_login_test.py" @@ -40,7 +36,27 @@ class TestLoader(unittest.TestCase): convert_testcase_path("/path/to 2/mubu.login.yml")[1], "MubuLogin" ) + self.assertEqual( + convert_testcase_path("mubu login.yml")[0], + "mubu_login_test.py" + ) self.assertEqual( convert_testcase_path("/path/to 2/mubu login.yml")[1], "MubuLogin" ) + self.assertEqual( + convert_testcase_path("/path/to 2/mubu-login.yml")[0], + "/path/to 2/mubu_login_test.py" + ) + self.assertEqual( + convert_testcase_path("/path/to 2/mubu-login.yml")[1], + "MubuLogin" + ) + self.assertEqual( + convert_testcase_path("/path/to 2/幕布login.yml")[0], + "/path/to 2/幕布login_test.py" + ) + self.assertEqual( + convert_testcase_path("/path/to/幕布login.yml")[1], + "幕布Login" + )