diff options
| author | Cyril Jouve <jv.cyril@gmail.com> | 2019-10-12 20:56:13 +0200 |
|---|---|---|
| committer | Cyril Jouve <jv.cyril@gmail.com> | 2019-10-13 19:42:15 +0200 |
| commit | 33b180120f30515d0f76fcf635cb8c76045b1b42 (patch) | |
| tree | 3e91875b3782b9f92af937248ab6e10d0a67ab10 /gitlab/tests/test_cli.py | |
| parent | 67a9c1f1c62393b02919d25bcc98c3683d92576a (diff) | |
| download | gitlab-33b180120f30515d0f76fcf635cb8c76045b1b42.tar.gz | |
feat(test): unused unittest2, type -> isinstance
Diffstat (limited to 'gitlab/tests/test_cli.py')
| -rw-r--r-- | gitlab/tests/test_cli.py | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/gitlab/tests/test_cli.py b/gitlab/tests/test_cli.py index 1485499..04a1961 100644 --- a/gitlab/tests/test_cli.py +++ b/gitlab/tests/test_cli.py @@ -16,12 +16,10 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from __future__ import print_function -from __future__ import absolute_import - import argparse import os import tempfile +import unittest try: from contextlib import redirect_stderr # noqa: H302 @@ -36,11 +34,6 @@ except ImportError: sys.stderr = old_target -try: - import unittest -except ImportError: - import unittest2 as unittest - import six from gitlab import cli @@ -120,19 +113,19 @@ class TestV4CLI(unittest.TestCase): def test_parser(self): parser = cli._get_parser(gitlab.v4.cli) - subparsers = None - for action in parser._actions: - if type(action) == argparse._SubParsersAction: - subparsers = action - break + subparsers = next( + action + for action in parser._actions + if isinstance(action, argparse._SubParsersAction) + ) self.assertIsNotNone(subparsers) self.assertIn("project", subparsers.choices) - user_subparsers = None - for action in subparsers.choices["project"]._actions: - if type(action) == argparse._SubParsersAction: - user_subparsers = action - break + user_subparsers = next( + action + for action in subparsers.choices["project"]._actions + if isinstance(action, argparse._SubParsersAction) + ) self.assertIsNotNone(user_subparsers) self.assertIn("list", user_subparsers.choices) self.assertIn("get", user_subparsers.choices) @@ -145,10 +138,10 @@ class TestV4CLI(unittest.TestCase): actions = user_subparsers.choices["create"]._option_string_actions self.assertFalse(actions["--description"].required) - user_subparsers = None - for action in subparsers.choices["group"]._actions: - if type(action) == argparse._SubParsersAction: - user_subparsers = action - break + user_subparsers = next( + action + for action in subparsers.choices["group"]._actions + if isinstance(action, argparse._SubParsersAction) + ) actions = user_subparsers.choices["create"]._option_string_actions self.assertTrue(actions["--name"].required) |
