Example #1
0
    def test_format_multiple_files_with_nonexistent_file(self):
        output_file = io.StringIO()

        result = pyformat.format_multiple_files(
            ['nonexistent_file'],
            pyformat.parse_args(['my_fake_program', '--in-place', '']),
            standard_out=output_file,
            standard_error=output_file)

        self.assertFalse(result)
Example #2
0
    def test_format_multiple_files_with_nonexistent_file(self):
        output_file = io.StringIO()

        result = pyformat.format_multiple_files(
            ['nonexistent_file'],
            pyformat.parse_args(['my_fake_program', '--in-place', '']),
            standard_out=output_file,
            standard_error=output_file)

        self.assertFalse(result)
Example #3
0
    def test_format_multiple_files_should_return_false_on_no_change(self):
        with temporary_file('''\
if True:
    x = 'abc'
''') as filename:
            output_file = io.StringIO()

            result = pyformat.format_multiple_files(
                [filename],
                pyformat.parse_args(['my_fake_program', '--in-place', '']),
                standard_out=output_file,
                standard_error=None)

            self.assertFalse(result[0])
Example #4
0
    def test_format_multiple_files_should_return_false_on_no_change(self):
        with temporary_file('''\
if True:
    x = 'abc'
''') as filename:
            output_file = io.StringIO()

            result = pyformat.format_multiple_files(
                [filename],
                pyformat.parse_args(['my_fake_program', '--in-place', '']),
                standard_out=output_file,
                standard_error=None)

            self.assertFalse(result)
Example #5
0
    def test_format_multiple_files(self):
        with temporary_file('''\
if True:
    x = "abc"
''') as filename:
            output_file = io.StringIO()

            result = pyformat.format_multiple_files(
                [filename],
                pyformat.parse_args(['my_fake_program', '--in-place', '']),
                standard_out=output_file,
                standard_error=None)

            self.assertTrue(result)

            with open(filename) as f:
                self.assertEqual('''\
if True:
    x = 'abc'
''', f.read())
Example #6
0
    def test_format_multiple_files(self):
        with temporary_file('''\
if True:
    x = "abc"
''') as filename:
            output_file = io.StringIO()

            result = pyformat.format_multiple_files(
                [filename],
                pyformat.parse_args(['my_fake_program', '--in-place', '']),
                standard_out=output_file,
                standard_error=None)

            self.assertTrue(result)

            with open(filename) as f:
                self.assertEqual('''\
if True:
    x = 'abc'
''', f.read())