From 844c1437f7ac3c2da817661f45afe8ec48607726 Mon Sep 17 00:00:00 2001 From: Erick Daniszewski Date: Wed, 16 Dec 2020 08:40:44 -0500 Subject: [PATCH] fmt: run source code formatting --- kubetest/objects/__init__.py | 2 +- kubetest/objects/networkpolicy.py | 34 +++++++++++++++---------------- kubetest/plugin.py | 8 ++++---- tests/conftest.py | 2 +- tox.ini | 1 + 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/kubetest/objects/__init__.py b/kubetest/objects/__init__.py index a636334..4ecfac8 100644 --- a/kubetest/objects/__init__.py +++ b/kubetest/objects/__init__.py @@ -20,4 +20,4 @@ from .secret import Secret from .service import Service from .serviceaccount import ServiceAccount -from .statefulset import StatefulSet \ No newline at end of file +from .statefulset import StatefulSet diff --git a/kubetest/objects/networkpolicy.py b/kubetest/objects/networkpolicy.py index ee7d217..c4a0f9a 100644 --- a/kubetest/objects/networkpolicy.py +++ b/kubetest/objects/networkpolicy.py @@ -25,9 +25,9 @@ class NetworkPolicy(ApiObject): obj_type = client.V1NetworkPolicy api_clients = { - 'preffered': client.NetworkingV1Api, - 'networking.k8s.io/v1': client.NetworkingV1Api, - } + 'preffered': client.NetworkingV1Api, + 'networking.k8s.io/v1': client.NetworkingV1Api, + } def __str__(self): return str(self.obj) @@ -48,16 +48,16 @@ def create(self, namespace: str = None) -> None: namespace = self.namespace log.info( - 'creating networkpolicy "%s" in namespace "%s"', - self.name, - self.namespace - ) + 'creating networkpolicy "%s" in namespace "%s"', + self.name, + self.namespace + ) log.debug('network_policy: %s', self.obj) self.obj = self.api_client.create_namespaced_network_policy( - namespace=namespace, - body=self.obj, - ) + namespace=namespace, + body=self.obj, + ) def delete(self, options: client.V1DeleteOptions = None) -> client.V1Status: """Delete the NetworkPolicy. @@ -80,17 +80,17 @@ def delete(self, options: client.V1DeleteOptions = None) -> client.V1Status: log.debug('network_policy: %s', self.obj) return self.api_client.delete_namespaced_network_policy( - name=self.name, - namespace=self.namespace, - body=options, - ) + name=self.name, + namespace=self.namespace, + body=options, + ) def refresh(self) -> None: """Refresh the underlying Kubernetes NetworkPolicy resource.""" self.obj = self.api_client.read_namespaced_network_policy( - name=self.name, - namespace=self.namespace, - ) + name=self.name, + namespace=self.namespace, + ) def is_ready(self) -> None: """Check if the NetworkPolicy is in the ready state. diff --git a/kubetest/plugin.py b/kubetest/plugin.py index 239b020..36ed2df 100644 --- a/kubetest/plugin.py +++ b/kubetest/plugin.py @@ -8,13 +8,12 @@ import logging import os import warnings +from typing import Optional import kubernetes import pytest import urllib3 -from typing import Optional - from kubetest import errors, markers from kubetest.client import TestClient from kubetest.manager import KubetestManager @@ -434,14 +433,15 @@ def kubeconfig(request) -> Optional[str]: @pytest.fixture def kubecontext(request) -> Optional[str]: - """Return the context in the kubeconfig to use for the tests. - + """Return the context in the kubeconfig to use for the tests. + When None, use the current context as set in the kubeconfig. """ context = request.session.config.getoption('kube_context') return context + @pytest.fixture() def kube(kubeconfig, kubecontext, request) -> TestClient: """Return a client for managing a Kubernetes cluster for testing.""" diff --git a/tests/conftest.py b/tests/conftest.py index f91f2ce..2a8975a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -275,5 +275,5 @@ def simple_networkpolicy(): spec=client.V1NetworkPolicySpec( pod_selector=client.V1LabelSelector(), policy_types=["Egress", "Ingress"], - ) + ) ) diff --git a/tox.ini b/tox.ini index 40180ff..8a6e04d 100644 --- a/tox.ini +++ b/tox.ini @@ -72,6 +72,7 @@ commands= [testenv:format] description= run basic formatting tools against the source code +basepython=python3 deps= isort>=5.0.0 autopep8