def test_input_file(self): # Set up mocks. input_file = mock.Mock(spec=io.BytesIO) input_file.read.return_value = b'' output_file = mock.Mock(spec=io.BytesIO) # Read the empty file; we should get empty output. py_docstring.main(input_file=input_file, output_file=output_file) output_file.write.assert_called_once_with(b'')
def test_real_input_file(self): output_file = io.BytesIO() # Use the input file for descriptor.proto. curdir = os.path.realpath(os.path.dirname(__file__)) with io.open('%s/data/input_buffer' % curdir, 'rb') as file_: py_docstring.main(input_file=file_, output_file=output_file) # Just ensure that the bytestream is the appropriate length. # This is a terrible test. :-/ assert len(output_file.getvalue()) == 25294
def test_input_file_buffer(self): # Ensure that the .buffer attribute is used if present. # This makes sys.stdin and sys.stdout be valid things to use # in Python 3. input_file = mock.Mock(spec=['buffer']) input_file.buffer = mock.Mock(spec=io.BytesIO) input_file.buffer.read.return_value = b'' output_file = mock.Mock(spec=['buffer']) output_file.buffer = mock.Mock(spec=io.BytesIO) # Read the empty file; we should get empty output. py_docstring.main(input_file=input_file, output_file=output_file) output_file.buffer.write.assert_called_once_with(b'')
import os from protoc_docs.bin import py_docstring if __name__ == '__main__': os.environ['PYPANDOC_PANDOC'] = os.path.join( os.path.abspath(__file__).rsplit("protoc_docs", 1)[0], "pandoc") py_docstring.main()