+ 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",
+ "-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):
+ for input in self.bad_inputs_list:
+ call = self.base_call.format(self.input_file)
+ call = call + " --stdout " + input
+ print(call)
+ proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
+ stdout,stderr = proc.communicate()
+ #print(proc.returncode)
+
+ # we want to check that the bad inputs were caught and sys.exit is stopping the code
+ print(stderr.decode("utf-8"))
+ self.assertNotEqual(proc.returncode,0)
+
+ def test_basic_regex(self):
+ for i, input in enumerate(self.good_inputs_list):
+
+ test_filename = "basic_{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)
+ if os.path.exists(test_file):
+ os.remove(test_file)
+
+ call = self.base_call_outs.format(self.input_file, self.test_output_dir)
+ call = call + " " + input
+ print(call)
+
+ proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
+ proc.wait()
+ copyfile(self.call_output, test_file)
+
+ test = pd.read_table(test_file)
+
+ baseline_file = os.path.join(".", self.baseline_output_dir, test_filename)
+ baseline = pd.read_table(baseline_file)
+ assert_frame_equal(test, baseline)
+ print(i)
+
+
+ def test_capturegroup_regex(self):
+ for i, input 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)
+ if os.path.exists(test_file):
+ os.remove(test_file)
+
+ call = self.base_call_outs.format(self.input_file, self.test_output_dir)
+ call = call + " " + input
+ print(call)
+
+ proc = subprocess.Popen(call,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
+ proc.wait()
+
+ copyfile(self.call_output, test_file)
+
+ test = pd.read_table(test_file)
+
+ baseline_file = os.path.join(".", self.baseline_output_dir, test_filename)
+ baseline = pd.read_table(baseline_file)
+ assert_frame_equal(test, baseline)
+
+