Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 3
0
 def test_open_file(self):
     matches = grep(".*unittest$", open(__file__.replace(".pyc", ".py")))
     self.assertEquals(matches, ['import unittest\n'])
Exemplo n.º 4
0
 def test_grep_multiple_files(self):
     matches = grep(".*unittest$", __file__.replace(".pyc", ".py"), "does_not_exist.txt")
     self.assertEquals(matches, ['import unittest\n'])
Exemplo n.º 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)
Exemplo n.º 6
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'])
Exemplo n.º 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'])
Exemplo n.º 8
0
 def test_open_file(self):
     matches = grep(".*unittest$", open(__file__.replace(".pyc", ".py")))
     self.assertEquals(matches, ['import unittest\n'])
Exemplo n.º 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'])
Exemplo n.º 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
Exemplo n.º 11
0
 def test_real_file(self):
     matches = grep(".*unittest$", __file__.replace(".pyc", ".py"))
     self.assertEquals(matches, ["import unittest\n"])