Exemple #1
0
 def file_grep(self, regexp, *fnames):
     """Returns lines matched in fnames, where fnames can either be
     pathnames to files to grep through or open file objects to grep through
     line by line.
     """
     return grep(regexp, *fnames)
Exemple #2
0
 def is_module_loaded(self, module_name):
     """Return whether specified moudle as module_name is loaded or not"""
     if len(grep("^" + module_name + " ", "/proc/modules")) == 0:
         return None
     else:
         return True
 def test_open_file(self):
     matches = grep(".*unittest$", open(__file__.replace(".pyc", ".py")))
     self.assertEquals(matches, ['import unittest\n'])
 def test_grep_multiple_files(self):
     matches = grep(".*unittest$", __file__.replace(".pyc", ".py"), "does_not_exist.txt")
     self.assertEquals(matches, ['import unittest\n'])
Exemple #5
0
 def file_grep(self, regexp, *fnames):
     """Returns lines matched in fnames, where fnames can either be
     pathnames to files to grep through or open file objects to grep through
     line by line.
     """
     return grep(regexp, *fnames)
 def test_file_obj(self):
     test_s = "\n".join(['this is only a test', 'there are only two lines'])
     test_fo = StringIO(test_s)
     matches = grep(".*test$", test_fo)
     self.assertEquals(matches, ['this is only a test\n'])
Exemple #7
0
 def test_grep_multiple_files(self):
     matches = grep(".*unittest$", __file__.replace(".pyc", ".py"), "does_not_exist.txt")
     self.assertEquals(matches, ['import unittest\n'])
Exemple #8
0
 def test_open_file(self):
     matches = grep(".*unittest$", open(__file__.replace(".pyc", ".py")))
     self.assertEquals(matches, ['import unittest\n'])
Exemple #9
0
 def test_file_obj(self):
     test_s = "\n".join(['this is only a test', 'there are only two lines'])
     test_fo = StringIO(test_s)
     matches = grep(".*test$", test_fo)
     self.assertEquals(matches, ['this is only a test\n'])
Exemple #10
0
 def is_module_loaded(self, module_name):
     """Return whether specified moudle as module_name is loaded or not"""
     if len(grep("^" + module_name + " ", "/proc/modules")) == 0:
         return None
     else:
         return True
 def test_real_file(self):
     matches = grep(".*unittest$", __file__.replace(".pyc", ".py"))
     self.assertEquals(matches, ["import unittest\n"])