Пример #1
0
    def test_open_quotes_with_pound(self):
        text = '''
        print """  this is text
          # and this is text
        # and this is too """
'''
        assert adjust_whitespace(text) == \
'''
Пример #2
0
    def test_basic(self):
        text = """
        for x in range(0,15):
            print x
        print "hi"
        """
        assert adjust_whitespace(text) == \
"""
Пример #3
0
    def test_basic(self):
        text = """
        for x in range(0,15):
            print x
        print "hi"
        """
        assert adjust_whitespace(text) == \
"""
Пример #4
0
    def test_open_quotes_with_pound(self):
        text = '''
        print """  this is text
          # and this is text
        # and this is too """
'''
        assert adjust_whitespace(text) == \
'''
Пример #5
0
    def test_quotes_with_pound(self):
        text = '''
        if True:
            """#"""
        elif False:
            "bar"
'''
        assert adjust_whitespace(text) == \
'''
Пример #6
0
    def test_quotes_with_pound(self):
        text = '''
        if True:
            """#"""
        elif False:
            "bar"
'''
        assert adjust_whitespace(text) == \
'''
Пример #7
0
 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
Пример #8
0
    def test_blank_lines(self):
        text = """
    print "hi"  # a comment

    # more comments

    print g
"""
        assert adjust_whitespace(text) == \
"""
Пример #9
0
 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
Пример #10
0
    def test_quotes(self):
        text = """
        print ''' aslkjfnas kjdfn
askdjfnaskfd fkasnf dknf sadkfjn asdkfjna sdakjn
asdkfjnads kfajns '''
        if x:
            print y
"""
        assert adjust_whitespace(text) == \
"""
Пример #11
0
 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
Пример #12
0
    def test_quotes(self):
        text = """
        print ''' aslkjfnas kjdfn
askdjfnaskfd fkasnf dknf sadkfjn asdkfjna sdakjn
asdkfjnads kfajns '''
        if x:
            print y
"""
        assert adjust_whitespace(text) == \
"""
Пример #13
0
    def test_blank_lines(self):
        text = """
    print "hi"  # a comment
    
    # more comments
    
    print g
"""
        assert adjust_whitespace(text) == \
"""
Пример #14
0
 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
Пример #15
0
 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
Пример #16
0
 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
Пример #17
0
    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) == \
"""
Пример #18
0
    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) == \
"""