diff options
author | Kate Case <kcase@redhat.com> | 2023-01-25 08:37:58 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-25 08:37:58 -0500 |
commit | e9911888f6dcdf9031f3fdb2e32c52e45815fdbe (patch) | |
tree | dc22abb4a329ef04e98685b81d074679dc24c456 /tests/unit/mock | |
parent | bcfe61a3b6ff69f08450f3dbd8f0f1827fb18ab3 (diff) | |
download | vyos.vyos-e9911888f6dcdf9031f3fdb2e32c52e45815fdbe.tar.gz vyos.vyos-e9911888f6dcdf9031f3fdb2e32c52e45815fdbe.zip |
Add prettier and isort to pre-commit. (#270)
* Add prettier and isort to pre-commit.
* Bump line-length to 100
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'tests/unit/mock')
-rw-r--r-- | tests/unit/mock/loader.py | 2 | ||||
-rw-r--r-- | tests/unit/mock/path.py | 6 | ||||
-rw-r--r-- | tests/unit/mock/procenv.py | 9 | ||||
-rw-r--r-- | tests/unit/mock/vault_helper.py | 5 | ||||
-rw-r--r-- | tests/unit/mock/yaml_helper.py | 34 |
5 files changed, 18 insertions, 38 deletions
diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py index aea5df56..258dccd9 100644 --- a/tests/unit/mock/loader.py +++ b/tests/unit/mock/loader.py @@ -23,8 +23,8 @@ __metaclass__ = type import os from ansible.errors import AnsibleParserError -from ansible.parsing.dataloader import DataLoader from ansible.module_utils._text import to_bytes, to_text +from ansible.parsing.dataloader import DataLoader class DictDataLoader(DataLoader): diff --git a/tests/unit/mock/path.py b/tests/unit/mock/path.py index 74b02be8..3962f24f 100644 --- a/tests/unit/mock/path.py +++ b/tests/unit/mock/path.py @@ -1,10 +1,8 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -from ansible_collections.vyos.vyos.tests.unit.compat.mock import MagicMock from ansible.utils.path import unfrackpath +from ansible_collections.vyos.vyos.tests.unit.compat.mock import MagicMock -mock_unfrackpath_noop = MagicMock( - spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x -) +mock_unfrackpath_noop = MagicMock(spec_set=unfrackpath, side_effect=lambda x, *args, **kwargs: x) diff --git a/tests/unit/mock/procenv.py b/tests/unit/mock/procenv.py index 1587949e..06987e31 100644 --- a/tests/unit/mock/procenv.py +++ b/tests/unit/mock/procenv.py @@ -21,14 +21,15 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -import sys import json - +import sys from contextlib import contextmanager from io import BytesIO, StringIO -from ansible_collections.vyos.vyos.tests.unit.compat import unittest -from ansible.module_utils.six import PY3 + from ansible.module_utils._text import to_bytes +from ansible.module_utils.six import PY3 + +from ansible_collections.vyos.vyos.tests.unit.compat import unittest @contextmanager diff --git a/tests/unit/mock/vault_helper.py b/tests/unit/mock/vault_helper.py index b34ae134..4c6c890c 100644 --- a/tests/unit/mock/vault_helper.py +++ b/tests/unit/mock/vault_helper.py @@ -17,7 +17,6 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible.module_utils._text import to_bytes - from ansible.parsing.vault import VaultSecret @@ -37,6 +36,4 @@ class TextVaultSecret(VaultSecret): @property def bytes(self): """The text encoded with encoding, unless we specifically set _bytes.""" - return self._bytes or to_bytes( - self.text, encoding=self.encoding, errors=self.errors - ) + return self._bytes or to_bytes(self.text, encoding=self.encoding, errors=self.errors) diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py index 5df30aae..540055d2 100644 --- a/tests/unit/mock/yaml_helper.py +++ b/tests/unit/mock/yaml_helper.py @@ -2,11 +2,11 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type import io -import yaml +import yaml from ansible.module_utils.six import PY3 -from ansible.parsing.yaml.loader import AnsibleLoader from ansible.parsing.yaml.dumper import AnsibleDumper +from ansible.parsing.yaml.loader import AnsibleLoader class YamlTestUtils(object): @@ -44,9 +44,7 @@ class YamlTestUtils(object): obj_2 = loader.get_data() # dump the gen 2 objects directory to strings - string_from_object_dump_2 = self._dump_string( - obj_2, dumper=AnsibleDumper - ) + string_from_object_dump_2 = self._dump_string(obj_2, dumper=AnsibleDumper) # The gen 1 and gen 2 yaml strings self.assertEqual(string_from_object_dump, string_from_object_dump_2) @@ -58,9 +56,7 @@ class YamlTestUtils(object): loader_3 = self._loader(stream_3) obj_3 = loader_3.get_data() - string_from_object_dump_3 = self._dump_string( - obj_3, dumper=AnsibleDumper - ) + string_from_object_dump_3 = self._dump_string(obj_3, dumper=AnsibleDumper) self.assertEqual(obj, obj_3) # should be transitive, but... @@ -92,12 +88,8 @@ class YamlTestUtils(object): stream_obj_from_string = io.StringIO() if PY3: - yaml.dump( - obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper - ) - yaml.dump( - obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper - ) + yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper) + yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper) else: yaml.dump( obj_from_stream, @@ -119,12 +111,8 @@ class YamlTestUtils(object): stream_obj_from_string.seek(0) if PY3: - yaml_string_obj_from_stream = yaml.dump( - obj_from_stream, Dumper=AnsibleDumper - ) - yaml_string_obj_from_string = yaml.dump( - obj_from_string, Dumper=AnsibleDumper - ) + yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper) + yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper) else: yaml_string_obj_from_stream = yaml.dump( obj_from_stream, Dumper=AnsibleDumper, encoding=None @@ -134,11 +122,7 @@ class YamlTestUtils(object): ) assert yaml_string == yaml_string_obj_from_stream - assert ( - yaml_string - == yaml_string_obj_from_stream - == yaml_string_obj_from_string - ) + assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string assert ( yaml_string == yaml_string_obj_from_stream |