mirror of
https://github.com/mirror/wget.git
synced 2025-01-27 12:50:13 +08:00
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'.
This commit is contained in:
parent
77e2c54991
commit
ea038006d1
@ -2,7 +2,6 @@
|
|||||||
from sys import exit
|
from sys import exit
|
||||||
from test.http_test import HTTPTest
|
from test.http_test import HTTPTest
|
||||||
from misc.wget_file import WgetFile
|
from misc.wget_file import WgetFile
|
||||||
import re
|
|
||||||
import hashlib
|
import hashlib
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
|
|
||||||
@ -12,9 +11,9 @@ from base64 import b64encode
|
|||||||
|
|
||||||
# Helper function for hostname, port and digest substitution
|
# Helper function for hostname, port and digest substitution
|
||||||
def SubstituteServerInfo (text, host, port, digest):
|
def SubstituteServerInfo (text, host, port, digest):
|
||||||
text = re.sub (r'{{FILE1_HASH}}', digest, text)
|
text = text.replace('{{FILE1_HASH}}', digest)
|
||||||
text = re.sub (r'{{SRV_HOST}}', host, text)
|
text = text.replace('{{SRV_HOST}}', host)
|
||||||
text = re.sub (r'{{SRV_PORT}}', str (port), text)
|
text = text.replace('{{SRV_PORT}}', str (port))
|
||||||
return text
|
return text
|
||||||
|
|
||||||
############# File Definitions ###############################################
|
############# File Definitions ###############################################
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
from sys import exit
|
from sys import exit
|
||||||
from test.http_test import HTTPTest
|
from test.http_test import HTTPTest
|
||||||
from misc.wget_file import WgetFile
|
from misc.wget_file import WgetFile
|
||||||
import re
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -77,9 +76,9 @@ http_test.server_setup()
|
|||||||
### Get and use dynamic server sockname
|
### Get and use dynamic server sockname
|
||||||
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()
|
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()
|
||||||
|
|
||||||
MetaXml = re.sub (r'{{FILE1_HASH}}', File1_sha256, MetaXml)
|
MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256)
|
||||||
MetaXml = re.sub (r'{{SRV_HOST}}', srv_host, MetaXml)
|
MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host)
|
||||||
MetaXml = re.sub (r'{{SRV_PORT}}', str (srv_port), MetaXml)
|
MetaXml = MetaXml.replace('{{SRV_PORT}}', str (srv_port))
|
||||||
MetaFile.content = MetaXml
|
MetaFile.content = MetaXml
|
||||||
|
|
||||||
err = http_test.begin ()
|
err = http_test.begin ()
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
from sys import exit
|
from sys import exit
|
||||||
from test.http_test import HTTPTest
|
from test.http_test import HTTPTest
|
||||||
from misc.wget_file import WgetFile
|
from misc.wget_file import WgetFile
|
||||||
import re
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -77,9 +76,9 @@ http_test.server_setup()
|
|||||||
### Get and use dynamic server sockname
|
### Get and use dynamic server sockname
|
||||||
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()
|
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()
|
||||||
|
|
||||||
MetaXml = re.sub (r'{{FILE1_HASH}}', File1_sha256, MetaXml)
|
MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256)
|
||||||
MetaXml = re.sub (r'{{SRV_HOST}}', srv_host, MetaXml)
|
MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host)
|
||||||
MetaXml = re.sub (r'{{SRV_PORT}}', str (srv_port), MetaXml)
|
MetaXml = MetaXml.replace('{{SRV_PORT}}', str (srv_port))
|
||||||
MetaFile.content = MetaXml
|
MetaFile.content = MetaXml
|
||||||
|
|
||||||
err = http_test.begin ()
|
err = http_test.begin ()
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
from sys import exit
|
from sys import exit
|
||||||
from test.http_test import HTTPTest
|
from test.http_test import HTTPTest
|
||||||
from misc.wget_file import WgetFile
|
from misc.wget_file import WgetFile
|
||||||
import re
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -77,9 +76,9 @@ http_test.server_setup()
|
|||||||
### Get and use dynamic server sockname
|
### Get and use dynamic server sockname
|
||||||
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()
|
srv_host, srv_port = http_test.servers[0].server_inst.socket.getsockname ()
|
||||||
|
|
||||||
MetaXml = re.sub (r'{{FILE1_HASH}}', File1_sha256, MetaXml)
|
MetaXml = MetaXml.replace('{{FILE1_HASH}}', File1_sha256)
|
||||||
MetaXml = re.sub (r'{{SRV_HOST}}', srv_host, MetaXml)
|
MetaXml = MetaXml.replace('{{SRV_HOST}}', srv_host)
|
||||||
MetaXml = re.sub (r'{{SRV_PORT}}', str (srv_port), MetaXml)
|
MetaXml = MetaXml.replace('{{SRV_PORT}}', str (srv_port))
|
||||||
MetaFile.content = MetaXml
|
MetaFile.content = MetaXml
|
||||||
|
|
||||||
err = http_test.begin ()
|
err = http_test.begin ()
|
||||||
|
Loading…
Reference in New Issue
Block a user