diff options
author | Matthew White <mehw.is.me@inventati.org> | 2016-09-12 07:19:41 +0200 |
---|---|---|
committer | Matthew White <mehw.is.me@inventati.org> | 2016-09-19 05:56:40 +0200 |
commit | ea038006d19bf9134df17f8ccc38cf0f1a586de3 (patch) | |
tree | a46d8ed3b6acc2104b1d1383f0ac8c8be8c6d210 /testenv | |
parent | 77e2c54991d5e423ebf01645abcb96d14282c701 (diff) | |
download | wget-ea038006d19bf9134df17f8ccc38cf0f1a586de3.tar.gz |
Use python .replace instead than re.sub in Metalink tests
* testenv/Test-metalink-http.py: Use python .replace
* testenv/Test-metalink-xml.py: Use python .replace
* testenv/Test-metalink-xml-abspath.py: Use python .replace
* testenv/Test-metalink-xml-relpath.py: Use python .replace
Use python .replace instead than re.sub, remove 'import re'.
Diffstat (limited to 'testenv')
-rwxr-xr-x | testenv/Test-metalink-http.py | 7 | ||||
-rwxr-xr-x | testenv/Test-metalink-xml-abspath.py | 7 | ||||
-rwxr-xr-x | testenv/Test-metalink-xml-relpath.py | 7 | ||||
-rwxr-xr-x | testenv/Test-metalink-xml.py | 7 |
4 files changed, 12 insertions, 16 deletions
diff --git a/testenv/Test-metalink-http.py b/testenv/Test-metalink-http.py index 993642b2..b119da62 100755 --- a/testenv/Test-metalink-http.py +++ b/testenv/Test-metalink-http.py @@ -2,7 +2,6 @@ from sys import exit from test.http_test import HTTPTest from misc.wget_file import WgetFile -import re import hashlib from base64 import b64encode @@ -12,9 +11,9 @@ from base64 import b64encode # Helper function for hostname, port and digest substitution def SubstituteServerInfo (text, host, port, digest): - text = re.sub (r'{{FILE1_HASH}}', digest, text) - text = re.sub (r'{{SRV_HOST}}', host, text) - text = re.sub (r'{{SRV_PORT}}', str (port), text) + text = text.replace('{{FILE1_HASH}}', digest) + text = text.replace('{{SRV_HOST}}', host) + text = text.replace('{{SRV_PORT}}', str (port)) return text ############# File Definitions ############################################### diff --git a/testenv/Test-metalink-xml-abspath.py b/testenv/Test-metalink-xml-abspath.py index b618ca01..4447b0e3 100755 --- a/testenv/Test-metalink-xml-abspath.py +++ b/testenv/Test-metalink-xml-abspath.py @@ -2,7 +2,6 @@ from sys import exit from test.http_test import HTTPTest from misc.wget_file import WgetFile -import re import hashlib """ @@ -77,9 +76,9 @@ http_test.server_setup() ### Get and use dynamic server sockname srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname () -MetaXml = re.sub (r'{{FILE1_HASH}}', File1_sha256, MetaXml) -MetaXml = re.sub (r'{{SRV_HOST}}', srv_host, MetaXml) -MetaXml = re.sub (r'{{SRV_PORT}}', str (srv_port), MetaXml) +MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256) +MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host) +MetaXml = MetaXml.replace('{{SRV_PORT}}', str (srv_port)) MetaFile.content = MetaXml err = http_test.begin () diff --git a/testenv/Test-metalink-xml-relpath.py b/testenv/Test-metalink-xml-relpath.py index 5ecb2b4c..c565302a 100755 --- a/testenv/Test-metalink-xml-relpath.py +++ b/testenv/Test-metalink-xml-relpath.py @@ -2,7 +2,6 @@ from sys import exit from test.http_test import HTTPTest from misc.wget_file import WgetFile -import re import hashlib """ @@ -77,9 +76,9 @@ http_test.server_setup() ### Get and use dynamic server sockname srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname () -MetaXml = re.sub (r'{{FILE1_HASH}}', File1_sha256, MetaXml) -MetaXml = re.sub (r'{{SRV_HOST}}', srv_host, MetaXml) -MetaXml = re.sub (r'{{SRV_PORT}}', str (srv_port), MetaXml) +MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256) +MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host) +MetaXml = MetaXml.replace('{{SRV_PORT}}', str (srv_port)) MetaFile.content = MetaXml err = http_test.begin () diff --git a/testenv/Test-metalink-xml.py b/testenv/Test-metalink-xml.py index 2541a384..fdeede64 100755 --- a/testenv/Test-metalink-xml.py +++ b/testenv/Test-metalink-xml.py @@ -2,7 +2,6 @@ from sys import exit from test.http_test import HTTPTest from misc.wget_file import WgetFile -import re import hashlib """ @@ -77,9 +76,9 @@ http_test.server_setup() ### Get and use dynamic server sockname srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname () -MetaXml = re.sub (r'{{FILE1_HASH}}', File1_sha256, MetaXml) -MetaXml = re.sub (r'{{SRV_HOST}}', srv_host, MetaXml) -MetaXml = re.sub (r'{{SRV_PORT}}', str (srv_port), MetaXml) +MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256) +MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host) +MetaXml = MetaXml.replace('{{SRV_PORT}}', str (srv_port)) MetaFile.content = MetaXml err = http_test.begin () |