mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-15 04:19:28 +08:00
add remove_prefix utils
This commit is contained in:
@@ -39,6 +39,13 @@ def get_sign(*args):
|
||||
sign = hmac.new(sign_key, content, hashlib.sha1).hexdigest()
|
||||
return sign
|
||||
|
||||
def remove_prefix(text, prefix):
|
||||
""" remove prefix from text
|
||||
"""
|
||||
if text.startswith(prefix):
|
||||
return text[len(prefix):]
|
||||
return text
|
||||
|
||||
def load_folder_files(folder_path, recursive=True):
|
||||
""" load folder path, return all files in list format.
|
||||
@param
|
||||
|
||||
@@ -8,6 +8,14 @@ from tests.base import ApiServerUnittest
|
||||
|
||||
class TestUtils(ApiServerUnittest):
|
||||
|
||||
def test_remove_prefix(self):
|
||||
full_url = "http://debugtalk.com/post/123"
|
||||
prefix = "http://debugtalk.com"
|
||||
self.assertEqual(
|
||||
utils.remove_prefix(full_url, prefix),
|
||||
"/post/123"
|
||||
)
|
||||
|
||||
def test_load_folder_files(self):
|
||||
folder = os.path.join(os.getcwd(), 'tests')
|
||||
file1 = os.path.join(os.getcwd(), 'tests', 'test_utils.py')
|
||||
|
||||
Reference in New Issue
Block a user