1
0
mirror of https://github.com/QData/TextAttack.git synced 2021-10-13 00:05:06 +03:00

fix tricky python 3.6 escape issue

This commit is contained in:
Jack Morris
2020-06-21 21:47:50 -04:00
parent 902f7f0940
commit 59fcc7ce40
2 changed files with 3 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ numpy
pandas
pyyaml>=5.1
scikit-learn
scipy
scipy==1.4.1
sentence_transformers
spacy
torch

View File

@@ -125,7 +125,8 @@ def test_command_line_attack(name, command, sample_output_file):
print("desired_output.encoded =>", desired_output.encode())
print("desired_output =>", desired_output)
# regex in sample file look like /.*/
desired_re = re.escape(desired_output).replace("/\\.\\*/", ".*")
# / is escaped in python 3.6, but not 3.7+, so we support both
desired_re = re.escape(desired_output).replace("/\\.\\*/", ".*").replace("\\/\\.\\*\\/", ".*")
result = run_command_and_get_result(command)
# get output and check match
assert result.stdout is not None