Skip to content

Commit

Permalink
assert for arg error usage print
Browse files Browse the repository at this point in the history
  • Loading branch information
hhatto committed Jun 23, 2024
1 parent 5805a66 commit 02592cc
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/test_autopep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -5513,8 +5513,12 @@ def test_diff_with_standard_in(self):

def test_indent_size_is_zero(self):
line = "'abc'\n"
with autopep8_subprocess(line, ['--indent-size=0']) as (_, retcode):
self.assertEqual(retcode, autopep8.EXIT_CODE_ARGPARSE_ERROR)
p = Popen(list(AUTOPEP8_CMD_TUPLE) + ['--indent-size=0', '-'],
stdout=PIPE, stderr=PIPE)
_, _err = p.communicate(line.encode('utf-8'))
self.assertEqual(p.returncode, autopep8.EXIT_CODE_ARGPARSE_ERROR)
self.assertIn('indent-size must be greater than 0\n', _err.decode('utf-8'))
self.assertIn('usage: autopep8', _err.decode('utf-8'))

def test_exit_code_with_io_error(self):
line = "import sys\ndef a():\n print(1)\n"
Expand Down Expand Up @@ -5940,6 +5944,22 @@ def test_exit_code_should_be_set_when_standard_in(self):
process.returncode,
autopep8.EXIT_CODE_EXISTS_DIFF)

def test_non_args(self):
process = Popen(list(AUTOPEP8_CMD_TUPLE) +
[],
stderr=PIPE,
stdout=PIPE,
stdin=PIPE)
_output, _error = process.communicate()
self.assertEqual(
process.returncode,
autopep8.EXIT_CODE_ARGPARSE_ERROR)
self.assertEqual(_output.decode("utf-8"), "")
self.assertIn(
"incorrect number of arguments\n",
_error.decode("utf-8"),
)


class ConfigurationTests(unittest.TestCase):

Expand Down

0 comments on commit 02592cc

Please sign in to comment.