Ejemplo n.º 1
0
    def test_format_docstrings(self):
        host = MockSystemHost()
        host.stdin = StringIO.StringIO(
            '''
def f():
    """
    triple-quoted docstring
    with multiple lines

    """
    x = """
    this is a regular multi-line string, not a docstring
    """
    return x
'''
        )
        main(host, ["-"])
        self.assertMultiLineEqual(
            host.stdout.getvalue(),
            '''
def f():
    """triple-quoted docstring
    with multiple lines
    """
    x = """
    this is a regular multi-line string, not a docstring
    """
    return x
''',
        )
Ejemplo n.º 2
0
    def test_format_docstrings(self):
        host = MockSystemHost()
        host.stdin = StringIO.StringIO('''
def f():
    """
    triple-quoted docstring
    with multiple lines

    """
    x = """
    this is a regular multi-line string, not a docstring
    """
    return x
''')
        main(host, ['-'])
        self.assertMultiLineEqual(
            host.stdout.getvalue(), '''
def f():
    """triple-quoted docstring
    with multiple lines
    """
    x = """
    this is a regular multi-line string, not a docstring
    """
    return x
''')
 def test_files_blink_no_backup(self):
     host = MockSystemHost()
     host.filesystem.files = {
         'test.py': ACTUAL_INPUT}
     main(host, ['--no-backups', 'test.py'])
     self.assertEqual(host.filesystem.files, {
         'test.py': EXPECTED_BLINK_OUTPUT})
Ejemplo n.º 4
0
 def test_files_blink(self):
     host = MockSystemHost()
     host.filesystem.files = {'test.py': ACTUAL_INPUT}
     main(host, ['test.py'])
     self.assertEqual(host.filesystem.files, {
         'test.py': EXPECTED_BLINK_OUTPUT,
         'test.py.bak': ACTUAL_INPUT
     })
 def test_files_blink(self):
     host = MockSystemHost()
     host.filesystem.files = {
         'test.py': ACTUAL_INPUT}
     main(host, ['test.py'])
     self.assertEqual(host.filesystem.files, {
         'test.py': EXPECTED_BLINK_OUTPUT,
         'test.py.bak': ACTUAL_INPUT})
Ejemplo n.º 6
0
    def test_format_docstrings_indentation(self):
        host = MockSystemHost()
        host.stdin = StringIO.StringIO('''
def f():
    """This is a docstring
       With extra indentation on this line.

     """
''')
        main(host, ['-'])
        self.assertMultiLineEqual(
            host.stdout.getvalue(), '''
def f():
    """This is a docstring
       With extra indentation on this line.
    """
''')
Ejemplo n.º 7
0
    def test_format_docstrings_indentation(self):
        host = MockSystemHost()
        host.stdin = StringIO.StringIO(
            '''
def f():
    """This is a docstring
       With extra indentation on this line.

     """
'''
        )
        main(host, ["-"])
        self.assertMultiLineEqual(
            host.stdout.getvalue(),
            '''
def f():
    """This is a docstring
       With extra indentation on this line.
    """
''',
        )
Ejemplo n.º 8
0
 def test_files_blink_no_backup(self):
     host = MockSystemHost()
     host.filesystem.files = {'test.py': ACTUAL_INPUT}
     main(host, ['--no-backups', 'test.py'])
     self.assertEqual(host.filesystem.files,
                      {'test.py': EXPECTED_BLINK_OUTPUT})
Ejemplo n.º 9
0
 def test_stdin_only_double_quoting(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ['--no-autopep8', '--double-quote-strings', '-'])
     self.assertMultiLineEqual(host.stdout.getvalue(),
                               EXPECTED_ONLY_DOUBLE_QUOTED_OUTPUT)
Ejemplo n.º 10
0
 def test_stdin_no_changes(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ['--no-autopep8', '--leave-strings-alone', '-'])
     self.assertMultiLineEqual(host.stdout.getvalue(), ACTUAL_INPUT)
Ejemplo n.º 11
0
 def test_stdin_no_changes(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ["--no-autopep8", "--leave-strings-alone", "-"])
     self.assertMultiLineEqual(host.stdout.getvalue(), ACTUAL_INPUT)
Ejemplo n.º 12
0
 def test_stdin_chromium(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ["--chromium", "-"])
     self.assertMultiLineEqual(host.stdout.getvalue(), EXPECTED_CHROMIUM_OUTPUT)
Ejemplo n.º 13
0
 def test_stdin_blink(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ["-"])
     self.assertMultiLineEqual(host.stdout.getvalue(), EXPECTED_BLINK_OUTPUT)
Ejemplo n.º 14
0
 def test_files_blink_no_backup(self):
     host = MockSystemHost()
     host.filesystem.files = {"test.py": ACTUAL_INPUT}
     main(host, ["--no-backups", "test.py"])
     self.assertEqual(host.filesystem.files, {"test.py": EXPECTED_BLINK_OUTPUT})
Ejemplo n.º 15
0
 def test_files_blink(self):
     host = MockSystemHost()
     host.filesystem.files = {"test.py": ACTUAL_INPUT}
     main(host, ["test.py"])
     self.assertEqual(host.filesystem.files, {"test.py": EXPECTED_BLINK_OUTPUT, "test.py.bak": ACTUAL_INPUT})
Ejemplo n.º 16
0
 def test_stdin_blink(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ['-'])
     self.assertMultiLineEqual(host.stdout.getvalue(),
                               EXPECTED_BLINK_OUTPUT)
Ejemplo n.º 17
0
 def test_stdin_chromium(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ['--chromium', '-'])
     self.assertMultiLineEqual(host.stdout.getvalue(),
                               EXPECTED_CHROMIUM_OUTPUT)
Ejemplo n.º 18
0
 def test_stdin_only_double_quoting(self):
     host = MockSystemHost()
     host.stdin = StringIO.StringIO(ACTUAL_INPUT)
     main(host, ["--no-autopep8", "--double-quote-strings", "-"])
     self.assertMultiLineEqual(host.stdout.getvalue(), EXPECTED_ONLY_DOUBLE_QUOTED_OUTPUT)
Ejemplo n.º 19
0
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys

from webkitpy.formatter.main import main

if __name__ == '__main__':
    sys.exit(main())
Ejemplo n.º 20
0
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys

from webkitpy.formatter.main import main


if __name__ == '__main__':
    sys.exit(main())