X-Git-Url: https://code.communitydata.science/mediawiki_dump_tools.git/blobdiff_plain/595728d8da09105c78e9e279cc1c258534ec10ae..b124f9c7c891b8b98441ef1b185ba1a1a4a32179:/test/Wikiq_Unit_Test.py?ds=sidebyside diff --git a/test/Wikiq_Unit_Test.py b/test/Wikiq_Unit_Test.py index 1b5ca3f..129abfe 100644 --- a/test/Wikiq_Unit_Test.py +++ b/test/Wikiq_Unit_Test.py @@ -289,12 +289,13 @@ class Test_Redirect_Ikwiki(unittest.TestCase): proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc.wait() - test_file = os.path.join(self.test_output_dir, "redirect_" + self.wikiq_out_name) + test_file = os.path.join("redirect_" + self.wikiq_out_name) copyfile(self.call_output, test_file) baseline_file = os.path.join(".", self.baseline_output_dir, test_file) # as a test let's make sure that we get equal data frames - test = pd.read_table(test_file) + test = pd.read_table(os.path.join(self.test_output_dir, test_file)) + baseline = pd.read_table(baseline_file) assert_frame_equal(test,baseline, check_like=True) @@ -326,12 +327,12 @@ class Test_Redirect_Wikia(unittest.TestCase): proc = subprocess.Popen(call,stdout=subprocess.PIPE,shell=True) proc.wait() - test_file = os.path.join(self.test_output_dir, "redirect_" + self.wikiq_out_name) + test_file = os.path.join("redirect_" + self.wikiq_out_name) copyfile(self.call_output, test_file) baseline_file = os.path.join(".", self.baseline_output_dir, test_file) # as a test let's make sure that we get equal data frames - test = pd.read_table(test_file) + test = pd.read_table(os.path.join(self.test_output_dir, test_file)) baseline = pd.read_table(baseline_file) assert_frame_equal(test,baseline, check_like=True) @@ -340,7 +341,7 @@ class Test_Redirect_Wikia(unittest.TestCase): class Test_Stdout(unittest.TestCase): def setUp(self): - self.wiki = 'itwiki' + self.wiki = 'sailormoon' self.wikiq_out_name = self.wiki + ".tsv" self.infile = "{0}.xml.7z".format(self.wiki) @@ -359,7 +360,8 @@ class Test_Stdout(unittest.TestCase): test_file = "noargs_" + self.wikiq_out_name baseline_file = os.path.join(".", self.baseline_output_dir, test_file) print(baseline_file) - test = pd.read_table(StringIO(outs)) + s = StringIO(outs) + test = pd.read_table(s) baseline = pd.read_table(baseline_file) assert_frame_equal(test,baseline, check_like=True) @@ -415,9 +417,9 @@ class Test_Regex(unittest.TestCase): def test_regex_inputs(self): - for input in self.bad_inputs_list: + for inpt in self.bad_inputs_list: call = self.base_call.format(self.input_file) - call = call + " --stdout " + input + call = call + " --stdout " + inpt print(call) proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) stdout,stderr = proc.communicate() @@ -428,7 +430,7 @@ class Test_Regex(unittest.TestCase): self.assertNotEqual(proc.returncode,0) def test_basic_regex(self): - for i, input in enumerate(self.good_inputs_list): + for i, inpt in enumerate(self.good_inputs_list): test_filename = "basic_{0}_{1}.tsv".format(self.wikiq_out_name[:-4], str(i)) #print(test_filename) @@ -437,7 +439,7 @@ class Test_Regex(unittest.TestCase): os.remove(test_file) call = self.base_call_outs.format(self.input_file, self.test_output_dir) - call = call + " " + input + call = call + " " + inpt print(call) proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True) @@ -453,7 +455,7 @@ class Test_Regex(unittest.TestCase): def test_capturegroup_regex(self): - for i, input in enumerate(self.cap_inputs_list): + for i, inpt in enumerate(self.cap_inputs_list): test_filename = "capturegroup_{0}_{1}.tsv".format(self.wikiq_out_name[:-4], str(i)) print(test_filename) test_file = os.path.join(self.test_output_dir, test_filename) @@ -461,7 +463,7 @@ class Test_Regex(unittest.TestCase): os.remove(test_file) call = self.base_call_outs.format(self.input_file, self.test_output_dir) - call = call + " " + input + call = call + " " + inpt print(call) proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)