Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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])
Ejemplo n.º 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)
Ejemplo n.º 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())
Ejemplo n.º 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())
Ejemplo n.º 7
0
    def test_jobs_less_than_one_should_default_to_cpu_count(self):
        args = pyformat.parse_args(['my_fake_program', '--jobs=0', __file__])

        self.assertGreater(args.jobs, 0)
Ejemplo n.º 8
0
    def test_jobs_less_than_one_should_default_to_cpu_count(self):
        args = pyformat.parse_args(['my_fake_program',
                                    '--jobs=0', __file__])

        self.assertGreater(args.jobs, 0)