Reformat Wikiq_Unit_Test.py

Separate out reformatting from editing.

Signed-off-by: Will Beason <willbeason@gmail.com>
This commit is contained in:
Will Beason 2025-05-26 15:07:39 -05:00
parent 9c5bf577e6
commit 09a84e7d11

View File

@ -9,6 +9,7 @@ import tracemalloc
tracemalloc.start() tracemalloc.start()
# with / without pwr DONE # with / without pwr DONE
# with / without url encode DONE # with / without url encode DONE
# with / without collapse user DONE # with / without collapse user DONE
@ -25,25 +26,25 @@ class Test_Wikipedia(unittest.TestCase):
os.mkdir("test_output") os.mkdir("test_output")
self.wiki = 'ikwiki-20180301-pages-meta-history' self.wiki = 'ikwiki-20180301-pages-meta-history'
self.wikiq_out_name = self.wiki + ".tsv" self.wikiq_out_name = self.wiki + ".tsv"
self.test_output_dir = os.path.join(".", "test_output") self.test_output_dir = os.path.join(".", "test_output")
self.call_output = os.path.join(self.test_output_dir, self.wikiq_out_name) self.call_output = os.path.join(self.test_output_dir, self.wikiq_out_name)
self.infile = "{0}.xml.bz2".format(self.wiki) self.infile = "{0}.xml.bz2".format(self.wiki)
self.base_call = "../wikiq {0} -o {1}" self.base_call = "../wikiq {0} -o {1}"
self.input_dir = "dumps" self.input_dir = "dumps"
self.input_file = os.path.join(".", self.input_dir,self.infile) self.input_file = os.path.join(".", self.input_dir, self.infile)
self.baseline_output_dir = "baseline_output" self.baseline_output_dir = "baseline_output"
def test_WP_url_encode(self): def test_WP_url_encode(self):
test_filename = "url-encode_" + self.wikiq_out_name test_filename = "url-encode_" + self.wikiq_out_name
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
call = call + " --url-encode" call = call + " --url-encode"
proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
@ -52,52 +53,51 @@ class Test_Wikipedia(unittest.TestCase):
# as a test let's make sure that we get equal data frames # as a test let's make sure that we get equal data frames
test = pd.read_table(test_file) test = pd.read_table(test_file)
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
def test_WP_namespaces(self): def test_WP_namespaces(self):
print(os.path.abspath('.')) print(os.path.abspath('.'))
test_filename = "namespaces_" + self.wikiq_out_name test_filename = "namespaces_" + self.wikiq_out_name
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
call = call + " -n 0 -n 1" call = call + " -n 0 -n 1"
print(call) print(call)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
baseline_file = os.path.join(os.path.abspath("."), self.baseline_output_dir, test_filename) baseline_file = os.path.join(os.path.abspath("."), self.baseline_output_dir, test_filename)
# as a test let's make sure that we get equal data frames # as a test let's make sure that we get equal data frames
test = pd.read_table(test_file) test = pd.read_table(test_file)
num_wrong_ns = sum(~ test.namespace.isin({0,1})) num_wrong_ns = sum(~ test.namespace.isin({0, 1}))
self.assertEqual(num_wrong_ns, 0) self.assertEqual(num_wrong_ns, 0)
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
def test_WP_revert_radius(self): def test_WP_revert_radius(self):
print(os.path.abspath('.')) print(os.path.abspath('.'))
test_filename = "revert_radius_" + self.wikiq_out_name test_filename = "revert_radius_" + self.wikiq_out_name
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
call = call + " -n 0 -n 1 -rr 1" call = call + " -n 0 -n 1 -rr 1"
print(call) print(call)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
baseline_file = os.path.join(os.path.abspath("."), self.baseline_output_dir, test_filename) baseline_file = os.path.join(os.path.abspath("."), self.baseline_output_dir, test_filename)
# as a test let's make sure that we get equal data frames # as a test let's make sure that we get equal data frames
test = pd.read_table(test_file) test = pd.read_table(test_file)
num_wrong_ns = sum(~ test.namespace.isin({0,1})) num_wrong_ns = sum(~ test.namespace.isin({0, 1}))
self.assertEqual(num_wrong_ns, 0) self.assertEqual(num_wrong_ns, 0)
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
class Test_Basic(unittest.TestCase): class Test_Basic(unittest.TestCase):
@ -107,25 +107,25 @@ class Test_Basic(unittest.TestCase):
os.mkdir("test_output") os.mkdir("test_output")
self.wiki = 'sailormoon' self.wiki = 'sailormoon'
self.wikiq_out_name = self.wiki + ".tsv" self.wikiq_out_name = self.wiki + ".tsv"
self.test_output_dir = os.path.join(".", "test_output") self.test_output_dir = os.path.join(".", "test_output")
self.call_output = os.path.join(self.test_output_dir, self.wikiq_out_name) self.call_output = os.path.join(self.test_output_dir, self.wikiq_out_name)
self.infile = "{0}.xml.7z".format(self.wiki) self.infile = "{0}.xml.7z".format(self.wiki)
self.base_call = "../wikiq {0} -o {1}" self.base_call = "../wikiq {0} -o {1}"
self.input_dir = "dumps" self.input_dir = "dumps"
self.input_file = os.path.join(".", self.input_dir,self.infile) self.input_file = os.path.join(".", self.input_dir, self.infile)
self.baseline_output_dir = "baseline_output" self.baseline_output_dir = "baseline_output"
def test_noargs(self): def test_noargs(self):
test_filename = "noargs_" + self.wikiq_out_name test_filename = "noargs_" + self.wikiq_out_name
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
@ -134,19 +134,18 @@ class Test_Basic(unittest.TestCase):
test = pd.read_table(test_file) test = pd.read_table(test_file)
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
def test_collapse_user(self): def test_collapse_user(self):
test_filename = "collapse-user_" + self.wikiq_out_name test_filename = "collapse-user_" + self.wikiq_out_name
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
call = call + " --collapse-user" call = call + " --collapse-user"
proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
@ -154,60 +153,57 @@ class Test_Basic(unittest.TestCase):
baseline_file = os.path.join(".", self.baseline_output_dir, test_filename) baseline_file = os.path.join(".", self.baseline_output_dir, test_filename)
test = pd.read_table(test_file) test = pd.read_table(test_file)
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
def test_pwr_segment(self): def test_pwr_segment(self):
test_filename = "persistence_segment_" + self.wikiq_out_name test_filename = "persistence_segment_" + self.wikiq_out_name
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
call = call + " --persistence segment" call = call + " --persistence segment"
proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
baseline_file = os.path.join(".", self.baseline_output_dir, test_filename) baseline_file = os.path.join(".", self.baseline_output_dir, test_filename)
test = pd.read_table(test_file) test = pd.read_table(test_file)
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
def test_pwr_legacy(self): def test_pwr_legacy(self):
test_filename = "persistence_legacy_" + self.wikiq_out_name test_filename = "persistence_legacy_" + self.wikiq_out_name
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
call = call + " --persistence legacy" call = call + " --persistence legacy"
proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
baseline_file = os.path.join(".", self.baseline_output_dir, test_filename) baseline_file = os.path.join(".", self.baseline_output_dir, test_filename)
test = pd.read_table(test_file) test = pd.read_table(test_file)
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
def test_pwr(self): def test_pwr(self):
test_filename = "persistence_" + self.wikiq_out_name test_filename = "persistence_" + self.wikiq_out_name
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
call = call + " --persistence" call = call + " --persistence"
proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
baseline_file = os.path.join(".", self.baseline_output_dir, test_filename) baseline_file = os.path.join(".", self.baseline_output_dir, test_filename)
@ -216,19 +212,18 @@ class Test_Basic(unittest.TestCase):
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
test = test.reindex(columns=sorted(test.columns)) test = test.reindex(columns=sorted(test.columns))
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
def test_url_encode(self): def test_url_encode(self):
test_filename = "url-encode_" + self.wikiq_out_name test_filename = "url-encode_" + self.wikiq_out_name
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
call = call + " --url-encode" call = call + " --url-encode"
proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
@ -237,7 +232,7 @@ class Test_Basic(unittest.TestCase):
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
test = test.reindex(columns=sorted(test.columns)) test = test.reindex(columns=sorted(test.columns))
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
class Test_Malformed(unittest.TestCase): class Test_Malformed(unittest.TestCase):
@ -246,42 +241,40 @@ class Test_Malformed(unittest.TestCase):
os.mkdir("test_output") os.mkdir("test_output")
self.wiki = 'twinpeaks' self.wiki = 'twinpeaks'
self.wikiq_out_name = self.wiki + ".tsv" self.wikiq_out_name = self.wiki + ".tsv"
self.test_output_dir = os.path.join(".", "test_output") self.test_output_dir = os.path.join(".", "test_output")
self.call_output = os.path.join(self.test_output_dir, self.wikiq_out_name) self.call_output = os.path.join(self.test_output_dir, self.wikiq_out_name)
self.infile = "{0}.xml.7z".format(self.wiki) self.infile = "{0}.xml.7z".format(self.wiki)
self.base_call = "../wikiq {0} -o {1}" self.base_call = "../wikiq {0} -o {1}"
self.input_dir = "dumps" self.input_dir = "dumps"
self.input_file = os.path.join(".", self.input_dir,self.infile) self.input_file = os.path.join(".", self.input_dir, self.infile)
def test_malformed_noargs(self): def test_malformed_noargs(self):
call = self.base_call.format(self.input_file, self.test_output_dir) call = self.base_call.format(self.input_file, self.test_output_dir)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE, shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
outs, errs = proc.communicate() outs, errs = proc.communicate()
errlines = str(errs).split("\\n") errlines = str(errs).split("\\n")
self.assertEqual(errlines[-2],'xml.etree.ElementTree.ParseError: no element found: line 1369, column 0') self.assertEqual(errlines[-2], 'xml.etree.ElementTree.ParseError: no element found: line 1369, column 0')
class Test_Stdout(unittest.TestCase): class Test_Stdout(unittest.TestCase):
def setUp(self): def setUp(self):
self.wiki = 'sailormoon' self.wiki = 'sailormoon'
self.wikiq_out_name = self.wiki + ".tsv" self.wikiq_out_name = self.wiki + ".tsv"
self.infile = "{0}.xml.7z".format(self.wiki) self.infile = "{0}.xml.7z".format(self.wiki)
self.base_call = "../wikiq {0} --stdout" self.base_call = "../wikiq {0} --stdout"
self.input_dir = "dumps" self.input_dir = "dumps"
self.input_file = os.path.join(".", self.input_dir,self.infile) self.input_file = os.path.join(".", self.input_dir, self.infile)
self.baseline_output_dir = "baseline_output" self.baseline_output_dir = "baseline_output"
def test_noargs(self): def test_noargs(self):
call = self.base_call.format(self.input_file) call = self.base_call.format(self.input_file)
print(call) print(call)
proc = subprocess.run(call,stdout=subprocess.PIPE,shell=True) proc = subprocess.run(call, stdout=subprocess.PIPE, shell=True)
outs = proc.stdout.decode("utf8") outs = proc.stdout.decode("utf8")
test_file = "noargs_" + self.wikiq_out_name test_file = "noargs_" + self.wikiq_out_name
@ -289,7 +282,8 @@ class Test_Stdout(unittest.TestCase):
print(baseline_file) print(baseline_file)
test = pd.read_table(StringIO(outs)) test = pd.read_table(StringIO(outs))
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test,baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
class Test_Regex(unittest.TestCase): class Test_Regex(unittest.TestCase):
@ -299,7 +293,7 @@ class Test_Regex(unittest.TestCase):
self.infile = "{0}.xml.bz2".format(self.wiki) self.infile = "{0}.xml.bz2".format(self.wiki)
self.input_dir = "dumps" self.input_dir = "dumps"
self.input_file = os.path.join(".", self.input_dir,self.infile) self.input_file = os.path.join(".", self.input_dir, self.infile)
if not os.path.exists("test_output"): if not os.path.exists("test_output"):
os.mkdir("test_output") os.mkdir("test_output")
@ -314,13 +308,13 @@ class Test_Regex(unittest.TestCase):
# sample inputs for checking that bad inputs get terminated / test_regex_inputs # sample inputs for checking that bad inputs get terminated / test_regex_inputs
self.bad_inputs_list = [ self.bad_inputs_list = [
#label is missing # label is missing
"-RP '\\b\\d+\\b'", "-RP '\\b\\d+\\b'",
#number of reg and number of labels do not match # number of reg and number of labels do not match
"-RP 'NPO V' -RP THE -RPl testlabel", "-RP 'NPO V' -RP THE -RPl testlabel",
#cp but rp label # cp but rp label
"-CP '(Tamil|Li)' -RPl testlabel", "-CP '(Tamil|Li)' -RPl testlabel",
#regex is missing # regex is missing
"-CPl testlabel", "-CPl testlabel",
"-RP '\\b\\w{3}\\b' -RPl threeletters -CP '\\b\\w{3}\\b'" "-RP '\\b\\w{3}\\b' -RPl threeletters -CP '\\b\\w{3}\\b'"
] ]
@ -330,35 +324,32 @@ class Test_Regex(unittest.TestCase):
"-RP '\\b\\d{3}\\b' -RPl threedigits", "-RP '\\b\\d{3}\\b' -RPl threedigits",
"-RP 'TestCase' -RP 'page' -RPl testcases -RPl page_word", "-RP 'TestCase' -RP 'page' -RPl testcases -RPl page_word",
"-CP 'Chevalier' -CPl chev_com -RP 'welcome to Wikipedia' -RPl wiki_welcome -CP 'Warning' -CPl warning", "-CP 'Chevalier' -CPl chev_com -RP 'welcome to Wikipedia' -RPl wiki_welcome -CP 'Warning' -CPl warning",
"-CP 'WP:EVADE' -CPl wp_evade" "-CP 'WP:EVADE' -CPl wp_evade"
] ]
self.cap_inputs_list = [ self.cap_inputs_list = [
"-RP 'Li Chevalier' -RPl li_cheval -CP '(?P<letter>\\b[a-zA-Z]{3}\\b)|(?P<number>\\b\\d+\\b)|(?P<cat>\\bcat\\b)' -CPl three", "-RP 'Li Chevalier' -RPl li_cheval -CP '(?P<letter>\\b[a-zA-Z]{3}\\b)|(?P<number>\\b\\d+\\b)|(?P<cat>\\bcat\\b)' -CPl three",
"-CP '(?P<a>\\bTestCaseA\\b)|(?P<b>\\bTestCaseB\\b)|(?P<c>\\bTestCaseC\\b)|(?P<d>\\bTestCaseD\\b)' -CPl testcase -RP '(?P<npov>npov|NPOV)|(?P<neutral>neutral point of view)' -RPl npov" "-CP '(?P<a>\\bTestCaseA\\b)|(?P<b>\\bTestCaseB\\b)|(?P<c>\\bTestCaseC\\b)|(?P<d>\\bTestCaseD\\b)' -CPl testcase -RP '(?P<npov>npov|NPOV)|(?P<neutral>neutral point of view)' -RPl npov"
] ]
def test_regex_inputs(self): def test_regex_inputs(self):
for input in self.bad_inputs_list: for input in self.bad_inputs_list:
call = self.base_call.format(self.input_file) call = self.base_call.format(self.input_file)
call = call + " --stdout " + input call = call + " --stdout " + input
print(call) print(call)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
stdout,stderr = proc.communicate() stdout, stderr = proc.communicate()
#print(proc.returncode) # print(proc.returncode)
# we want to check that the bad inputs were caught and sys.exit is stopping the code # we want to check that the bad inputs were caught and sys.exit is stopping the code
print(stderr.decode("utf-8")) print(stderr.decode("utf-8"))
self.assertNotEqual(proc.returncode,0) self.assertNotEqual(proc.returncode, 0)
def test_basic_regex(self): def test_basic_regex(self):
for i, input in enumerate(self.good_inputs_list): for i, input in enumerate(self.good_inputs_list):
test_filename = "basic_{0}_{1}.tsv".format(self.wikiq_out_name[:-4], str(i)) test_filename = "basic_{0}_{1}.tsv".format(self.wikiq_out_name[:-4], str(i))
#print(test_filename) # print(test_filename)
test_file = os.path.join(self.test_output_dir, test_filename) test_file = os.path.join(self.test_output_dir, test_filename)
if os.path.exists(test_file): if os.path.exists(test_file):
os.remove(test_file) os.remove(test_file)
@ -367,18 +358,17 @@ class Test_Regex(unittest.TestCase):
call = call + " " + input call = call + " " + input
print(call) print(call)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
test = pd.read_table(test_file) test = pd.read_table(test_file)
baseline_file = os.path.join(".", self.baseline_output_dir, test_filename) baseline_file = os.path.join(".", self.baseline_output_dir, test_filename)
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test, baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)
print(i) print(i)
def test_capturegroup_regex(self): def test_capturegroup_regex(self):
for i, input in enumerate(self.cap_inputs_list): for i, input in enumerate(self.cap_inputs_list):
test_filename = "capturegroup_{0}_{1}.tsv".format(self.wikiq_out_name[:-4], str(i)) test_filename = "capturegroup_{0}_{1}.tsv".format(self.wikiq_out_name[:-4], str(i))
@ -391,13 +381,13 @@ class Test_Regex(unittest.TestCase):
call = call + " " + input call = call + " " + input
print(call) print(call)
proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) proc = subprocess.Popen(call, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
proc.wait() proc.wait()
copyfile(self.call_output, test_file) copyfile(self.call_output, test_file)
test = pd.read_table(test_file) test = pd.read_table(test_file)
baseline_file = os.path.join(".", self.baseline_output_dir, test_filename) baseline_file = os.path.join(".", self.baseline_output_dir, test_filename)
baseline = pd.read_table(baseline_file) baseline = pd.read_table(baseline_file)
assert_frame_equal(test, baseline, check_like=True) assert_frame_equal(test, baseline, check_like=True)