示例#1
0
 def test_output(self):
     parser = procsci.PoSParser()
     mock_infile = os.path.join(os.path.dirname(__file__), "data/stubdata/input/pos_sissa_it_299.html")
     mock_data = open(mock_infile, 'rU').read()
     self.urlopen_mock.return_value = MockResponse(mock_data)
     test_data = parser.parse("https://pos.sissa.it/299")
     test_outfile = "test_pos.tag"
     standard_outfile = os.path.join(os.path.dirname(__file__), "data/stubdata/serialized/procsci_299.tag")
     try:
         os.remove(test_outfile)
     except Exception, err:
         pass
 def test_output(self):
     parser = procsci.PoSParser()
     mock_infile = "test_data/stubdata/input/pos_sissa_it_299.html"
     mock_data = open(mock_infile, 'rU').read()
     self.urlopen_mock.return_value = MockResponse(mock_data)
     test_data = parser.parse("https://pos.sissa.it/299")
     test_outfile = "test_pos.tag"
     standard_outfile = "test_data/stubdata/serialized/procsci_299.tag"
     try:
         os.remove(test_outfile)
     except:
         pass
     for d in test_data:
         serializer = classic.Tagged()
         outputfp = open(test_outfile, 'a')
         serializer.write(d, outputfp)
         outputfp.close()
     result = filecmp.cmp(test_outfile, standard_outfile)
     self.assertEqual(result, True)
     os.remove(test_outfile)
示例#3
0
 def test_output(self):
     parser = procsci.PoSParser()
     mock_infile = os.path.join(os.path.dirname(__file__), "data/stubdata/input/pos_sissa_it_299.html")
     mock_data = open(mock_infile, open_mode_u).read()
     self.requests_mock.return_value.text = MockResponse(mock_data)
     test_data = parser.parse("https://pos.sissa.it/299_test")
     test_outfile = "test_pos.tag"
     standard_outfile = os.path.join(os.path.dirname(__file__), "data/stubdata/serialized/procsci_299.tag")
     try:
         os.remove(test_outfile)
     except Exception as err:
         pass
     for d in test_data:
         serializer = classic.Tagged()
         outputfp = open(test_outfile, 'a')
         serializer.write(d, outputfp)
         outputfp.close()
     result = filecmp.cmp(test_outfile, standard_outfile)
     self.assertEqual(result, True)
     os.remove(test_outfile)
示例#4
0
 def test_badsite(self):
     parser = procsci.PoSParser()
     with self.assertRaises(procsci.URLError):
         test_data = parser.parse("https://www.cnn.com")