Skip to content

Commit 4ec7f4f

Browse files
committed
Modernize speedtest
1 parent b7193b6 commit 4ec7f4f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

diff_match_patch/tests/speedtest.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,20 @@
1818
"""
1919

2020
import gc
21-
import imp
22-
import os
23-
import sys
21+
import importlib
22+
import pkgutil
2423
import time
2524

26-
parentPath = os.path.abspath("..")
27-
if parentPath not in sys.path:
28-
sys.path.insert(0, parentPath)
2925
import diff_match_patch as dmp_module
3026

3127
# Force a module reload. Allows one to edit the DMP module and rerun the test
3228
# without leaving the Python interpreter.
33-
imp.reload(dmp_module)
29+
importlib.reload(dmp_module)
3430

3531

3632
def main():
37-
text1 = open("speedtest1.txt").read()
38-
text2 = open("speedtest2.txt").read()
33+
text1 = pkgutil.get_data("diff_match_patch.tests", "speedtest1.txt").decode()
34+
text2 = pkgutil.get_data("diff_match_patch.tests", "speedtest2.txt").decode()
3935

4036
dmp = dmp_module.diff_match_patch()
4137
dmp.Diff_Timeout = 0.0

0 commit comments

Comments
 (0)