def test_var(self): fLOG (__file__, self._testMethodName, OutputPrint = __name__ == "__main__") docstring = """ This class opens a text file as if it were a binary file. It can deal with null characters which are missed by open function. @var filename file name @var utf8 decode in utf8 @var errors decoding in utf8 can raise some errors, @see cl str to understand the meaning of this parameter @var fLOG logging function (@see fn fLOG) @var _buffer_size read a text file _buffer_size bytes each time @var _filter function filter, None or return True or False whether a line should considered or not Example: @code f = TextFile (filename) f.open () for line in f : print line f.close () @endcode """ values = process_var_tag(docstring) assert len(values) == 6 rst = process_var_tag(docstring, True) fLOG(rst) assert len(rst) > 0
def test_process_var_tag(self): fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") test_string = """ This is the documentation for this class. @var pa an example of an attribute. Inline :math:`x^2 + y + z`. Another equation to test: .. math:: x^2 + y .. math:: \\sum_{i=1}^n x^2 """ rst = process_var_tag(test_string, True) exp = """ This is the documentation for this class. +-----------+-----------------------------+ | attribute | meaning | +===========+=============================+ | pa | an example of an attribute. | +-----------+-----------------------------+ Inline :math:`x^2 + y + z`. Another equation to test: .. math:: x^2 + y .. math:: \sum_{i=1}^n x^2 """ self.assertEqual(rst.strip("\n ").replace(" ", ""), exp.strip("\n ").replace(" ", ""))