From 9b154c75b9ba40cff5699d1466ce3d3f1e40d74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Szulc?= Date: Fri, 13 Dec 2024 15:14:17 +0100 Subject: [PATCH] Fix flake Fix coverage hopefully --- pyproject.toml | 1 + src/ralph/dhcp/agent/dhcp_agent.py | 6 +++--- src/ralph/dhcp/agent/test.py | 10 +++++++--- src/ralph/dhcp/tests/test_agent.py | 2 +- src/ralph/settings/test.py | 2 -- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6f090e4818..7ec7a7d428 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,7 @@ requires = ["setuptools<66.0"] build-backend = "setuptools.build_meta" [tools.coverage.run] +sources = ralph branch = 1 [tools.coverage.report] diff --git a/src/ralph/dhcp/agent/dhcp_agent.py b/src/ralph/dhcp/agent/dhcp_agent.py index 9259517116..70c3455c38 100644 --- a/src/ralph/dhcp/agent/dhcp_agent.py +++ b/src/ralph/dhcp/agent/dhcp_agent.py @@ -25,9 +25,9 @@ from urllib.request import Request, urlopen string_types = (str,) except: # noqa - from urllib import urlencode - from urllib2 import HTTPError, Request, urlopen - string_types = (basestring,) + from urllib import urlencode # noqa + from urllib2 import HTTPError, Request, urlopen # noqa + string_types = (basestring,) # noqa APP_DIR = os.path.expanduser('~/.ralph-dhcp-agent') diff --git a/src/ralph/dhcp/agent/test.py b/src/ralph/dhcp/agent/test.py index c75c80e1ff..52677d1c26 100644 --- a/src/ralph/dhcp/agent/test.py +++ b/src/ralph/dhcp/agent/test.py @@ -2,13 +2,14 @@ import unittest from optparse import Values +from mock import MagicMock, Mock, patch + from ralph.dhcp.agent.dhcp_agent import ( - Cache, - DHCPConfigManager, _check_params, _get_cmd_params_from_parser, + Cache, + DHCPConfigManager ) -from mock import MagicMock, Mock, patch logger = logging.getLogger(__file__) mocked_parser = MagicMock() @@ -23,8 +24,11 @@ def mocked_read(self): } return type('response', (object,), attrs) + def mocked_error(msg): raise Exception(msg) + + mocked_parser.error = mocked_error default_params = { diff --git a/src/ralph/dhcp/tests/test_agent.py b/src/ralph/dhcp/tests/test_agent.py index 84fef326d1..b2284c6c8b 100644 --- a/src/ralph/dhcp/tests/test_agent.py +++ b/src/ralph/dhcp/tests/test_agent.py @@ -4,8 +4,8 @@ from django.contrib.auth import get_user_model from django.test import LiveServerTestCase -from ralph.dhcp.agent.dhcp_agent import Cache, DHCPConfigManager from ralph.data_center.tests.factories import DataCenterFactory +from ralph.dhcp.agent.dhcp_agent import Cache, DHCPConfigManager from ralph.dhcp.models import DHCPServer logger = logging.getLogger(__file__) diff --git a/src/ralph/settings/test.py b/src/ralph/settings/test.py index 720d2368cd..1eafa8bdd2 100644 --- a/src/ralph/settings/test.py +++ b/src/ralph/settings/test.py @@ -1,5 +1,3 @@ -import sys - from ralph.settings import * # noqa DEBUG = False