fix: compatibility with testcase file path includes minus sign

This commit is contained in:
debugtalk
2020-05-17 12:45:03 +08:00
parent bf96c6519a
commit f3f2ed10f5
3 changed files with 22 additions and 6 deletions

View File

@@ -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

View File

@@ -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")

View File

@@ -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"
)