Skip to content

Commit 4d8c401

Browse files
Add tests for long options
1 parent 4d487cf commit 4d8c401

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

Lib/test/test_base64.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,8 +1422,9 @@ def get_output(self, *args):
14221422
def test_encode_file(self):
14231423
with open(os_helper.TESTFN, 'wb') as fp:
14241424
fp.write(b'a\xffb\n')
1425-
output = self.get_output('-e', os_helper.TESTFN)
1426-
self.assertEqual(output.rstrip(), b'Yf9iCg==')
1425+
for flag in ('-e', '--encode'):
1426+
output = self.get_output(flag, os_helper.TESTFN)
1427+
self.assertEqual(output.rstrip(), b'Yf9iCg==')
14271428

14281429
def test_encode_from_stdin(self):
14291430
with script_helper.spawn_python('-m', 'base64', '-e') as proc:
@@ -1434,13 +1435,15 @@ def test_encode_from_stdin(self):
14341435
def test_decode(self):
14351436
with open(os_helper.TESTFN, 'wb') as fp:
14361437
fp.write(b'Yf9iCg==')
1437-
output = self.get_output('-d', os_helper.TESTFN)
1438-
self.assertEqual(output.rstrip(), b'a\xffb')
1438+
for flag in ('-d', '--decode'):
1439+
output = self.get_output(flag, os_helper.TESTFN)
1440+
self.assertEqual(output.rstrip(), b'a\xffb')
14391441

14401442
def test_prints_usage_with_help_flag(self):
1441-
output = self.get_output('-h')
1442-
self.assertIn(b'usage: ', output)
1443-
self.assertIn(b'-d', output)
1443+
for flag in ('-h', '--help'):
1444+
output = self.get_output(flag)
1445+
self.assertIn(b'usage: ', output)
1446+
self.assertIn(b'-d', output)
14441447

14451448
def test_prints_usage_with_invalid_flag(self):
14461449
output = script_helper.assert_python_failure('-m', 'base64', '-x').err

0 commit comments

Comments
 (0)