fix: compatibility with testcase file path includes minus sign

This commit is contained in:
debugtalk
2020-05-17 12:45:03 +08:00
parent a303610b8c
commit a5cc532541
3 changed files with 22 additions and 6 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
**Fixed** **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: testcase generator, validate content.xxx => body.xxx
- fix: scaffold for v3 - fix: scaffold for v3
+1 -1
View File
@@ -41,7 +41,7 @@ def convert_testcase_path(testcase_path: Text) -> Tuple[Text, Text]:
if file_suffix not in [".json", ".yml", ".yaml"]: if file_suffix not in [".json", ".yml", ".yaml"]:
raise exceptions.ParamsError("") 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_dir = os.path.dirname(testcase_path)
testcase_python_path = os.path.join(testcase_dir, f"{file_name}_test.py") testcase_python_path = os.path.join(testcase_dir, f"{file_name}_test.py")
+20 -4
View File
@@ -24,10 +24,6 @@ class TestLoader(unittest.TestCase):
convert_testcase_path("mubu.login.yml")[0], convert_testcase_path("mubu.login.yml")[0],
"mubu_login_test.py" "mubu_login_test.py"
) )
self.assertEqual(
convert_testcase_path("mubu login.yml")[0],
"mubu_login_test.py"
)
self.assertEqual( self.assertEqual(
convert_testcase_path("/path/to/mubu.login.yml")[0], convert_testcase_path("/path/to/mubu.login.yml")[0],
"/path/to/mubu_login_test.py" "/path/to/mubu_login_test.py"
@@ -40,7 +36,27 @@ class TestLoader(unittest.TestCase):
convert_testcase_path("/path/to 2/mubu.login.yml")[1], convert_testcase_path("/path/to 2/mubu.login.yml")[1],
"MubuLogin" "MubuLogin"
) )
self.assertEqual(
convert_testcase_path("mubu login.yml")[0],
"mubu_login_test.py"
)
self.assertEqual( self.assertEqual(
convert_testcase_path("/path/to 2/mubu login.yml")[1], convert_testcase_path("/path/to 2/mubu login.yml")[1],
"MubuLogin" "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"
)