def test_open_quotes_with_pound(self): text = ''' print """ this is text # and this is text # and this is too """ ''' assert adjust_whitespace(text) == \ '''
def test_basic(self): text = """ for x in range(0,15): print x print "hi" """ assert adjust_whitespace(text) == \ """
def test_quotes_with_pound(self): text = ''' if True: """#""" elif False: "bar" ''' assert adjust_whitespace(text) == \ '''
def match_python_block(self): match = self.match(r"<%(!)?") if match: (line, pos) = (self.matched_lineno, self.matched_charpos) (text, end) = self.parse_until_text(r'%>') text = adjust_whitespace(text) + "\n" # the trailing newline helps compiler.parse() not complain about indentation self.append_node(parsetree.Code, self.escape_code(text), match.group(1)=='!', lineno=line, pos=pos) return True else: return False
def test_blank_lines(self): text = """ print "hi" # a comment # more comments print g """ assert adjust_whitespace(text) == \ """
def test_quotes(self): text = """ print ''' aslkjfnas kjdfn askdjfnaskfd fkasnf dknf sadkfjn asdkfjna sdakjn asdkfjnads kfajns ''' if x: print y """ assert adjust_whitespace(text) == \ """
def match_python_block(self): match = self.match(r"<%(!)?") if match: (line, pos) = (self.matched_lineno, self.matched_charpos) (text, end) = self.parse_until_text(r'%>') text = adjust_whitespace(text) self.append_node(parsetree.Code, self.escape_code(text), match.group(1)=='!', lineno=line, pos=pos) return True else: return False
def match_python_block(self): match = self.match(r"<%(!)?") if match: line, pos = self.matched_lineno, self.matched_charpos text, end = self.parse_until_text(False, r"%>") # the trailing newline helps # compiler.parse() not complain about indentation text = adjust_whitespace(text) + "\n" self.append_node(parsetree.Code, text, match.group(1) == "!", lineno=line, pos=pos) return True else: return False
def match_python_block(self): match = self.match(r"<%(!)?") if match: line, pos = self.matched_lineno, self.matched_charpos text, end = self.parse_until_text(False, r"%>") # the trailing newline helps # compiler.parse() not complain about indentation text = adjust_whitespace(text) + "\n" self.append_node( parsetree.Code, text, match.group(1) == "!", lineno=line, pos=pos, ) return True else: return False
def match_python_block(self): match = self.match(r"<%(!)?") if match: (line, pos) = (self.matched_lineno, self.matched_charpos) (text, end) = self.parse_until_text(r'%>') text = adjust_whitespace(text) self.append_node(parsetree.Code, self.escape_code(text), match.group(1) == '!', lineno=line, pos=pos) return True else: return False
def test_quote_with_comments(self): text= """ print 'hi' # this is a comment # another comment x = 7 # someone's '''comment print ''' there ''' # someone else's comment """ assert adjust_whitespace(text) == \ """
def test_quote_with_comments(self): text = """ print 'hi' # this is a comment # another comment x = 7 # someone's '''comment print ''' there ''' # someone else's comment """ assert adjust_whitespace(text) == \ """