fix: compatibility with different path separators of Linux and Windows

This commit is contained in:
debugtalk
2020-06-14 22:01:09 +08:00
parent f4382139db
commit 5f17296042
4 changed files with 33 additions and 1 deletions

View File

@@ -2,7 +2,7 @@ import os
import unittest
from httprunner import compat, exceptions, loader
from httprunner.compat import convert_variables
from httprunner.compat import convert_variables, ensure_path_sep
class TestCompat(unittest.TestCase):
@@ -213,3 +213,19 @@ class TestCompat(unittest.TestCase):
"--self-contained-html",
],
)
def test_ensure_file_path(self):
self.assertEqual(
ensure_path_sep("demo\\test.yml"), os.sep.join(["demo", "test.yml"])
)
self.assertEqual(
ensure_path_sep(os.path.join(os.getcwd(), "demo\\test.yml")),
os.path.join(os.getcwd(), os.sep.join(["demo", "test.yml"])),
)
self.assertEqual(
ensure_path_sep("demo/test.yml"), os.sep.join(["demo", "test.yml"])
)
self.assertEqual(
ensure_path_sep(os.path.join(os.getcwd(), "demo/test.yml")),
os.path.join(os.getcwd(), os.sep.join(["demo", "test.yml"])),
)