def is_single_block(string): codeblock = ch.CodeBlock(0) codeblock.string = '\n'.join(s.rstrip(' ') for s in ''.join(ch.xreadlines(string.expandtabs())).split('\n')) block_list = list( ch.iterblocks(ch.xreadlines(string)) ) assert_equal(line_list_signature([codeblock]), line_list_signature(block_list))
def is_single_block(string): codeblock = ch.CodeBlock(0) codeblock.string = '\n'.join( s.rstrip(' ') for s in ''.join(ch.xreadlines(string.expandtabs())).split('\n')) block_list = list(ch.iterblocks(ch.xreadlines(string))) assert_equal(line_list_signature([codeblock]), line_list_signature(block_list))
def test_double_function_non_empty_line(): string = """ def f(): \tpass \t def g(): \tpass """ blocks = list(ch.iterblocks(ch.xreadlines(string))) # This should be made of three blocks, the last one of them # empty. assert_equal(len(blocks), 3)
def check_signature(in_string, signature): hasher = ch.CodeHasher(ch.xreadlines(in_string)) code_line_list = [l for l in hasher.itercodelines()] signature2 = line_list_signature(code_line_list) assert_equal(signature, signature2)
def is_same_code(codestring): out = ''.join([i.string for i in ch.iterblocks(ch.xreadlines(codestring))]) assert_equal(codestring.expandtabs(), out)
def test_hello_world(self): main.main(xreadlines("print 'hello world'"), overrides={'outfile':self.outString, 'outtype':'rst', 'quiet':True, 'noecho':True }), self.assertEqual(self.outString.getvalue(), ".. header:: Compiled with pyreport\n\n\n::\n\n print 'hello world'\n \n\n.. class:: answer\n\n ::\n\n hello world\n \n \n\n")
def test_empty_file(self): main.main(xreadlines(""), overrides={'outfile':self.outString, 'outtype':'rst', 'quiet':True}), self.assertEqual(self.outString.getvalue(), '.. header:: Compiled with pyreport\n\n\n\n')