Skip to content

Commit 02592cc

Browse files
committed
assert for arg error usage print
1 parent 5805a66 commit 02592cc

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

test/test_autopep8.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5513,8 +5513,12 @@ def test_diff_with_standard_in(self):
55135513

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

55195523
def test_exit_code_with_io_error(self):
55205524
line = "import sys\ndef a():\n print(1)\n"
@@ -5940,6 +5944,22 @@ def test_exit_code_should_be_set_when_standard_in(self):
59405944
process.returncode,
59415945
autopep8.EXIT_CODE_EXISTS_DIFF)
59425946

5947+
def test_non_args(self):
5948+
process = Popen(list(AUTOPEP8_CMD_TUPLE) +
5949+
[],
5950+
stderr=PIPE,
5951+
stdout=PIPE,
5952+
stdin=PIPE)
5953+
_output, _error = process.communicate()
5954+
self.assertEqual(
5955+
process.returncode,
5956+
autopep8.EXIT_CODE_ARGPARSE_ERROR)
5957+
self.assertEqual(_output.decode("utf-8"), "")
5958+
self.assertIn(
5959+
"incorrect number of arguments\n",
5960+
_error.decode("utf-8"),
5961+
)
5962+
59435963

59445964
class ConfigurationTests(unittest.TestCase):
59455965

0 commit comments

Comments
 (0)