Skip to content

Commit c9748c6

Browse files
committed
TST: Refactor imports in Monte Carlo plot tests for consistency
- Moved import statements for numpy and rocketpy.tools to the top of the test functions to adhere to best practices and improve readability. - Added pylint disable comments for imports outside of the top-level to maintain code quality standards.
1 parent 2e53b53 commit c9748c6

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

tests/unit/simulation/test_monte_carlo_plots_background.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# pylint: disable=unused-argument,assignment-from-no-return
22
import os
33
import urllib.error # pylint: disable=unused-import
4-
import pytest
54
from unittest.mock import MagicMock, patch
65

6+
import pytest
7+
78
import matplotlib.pyplot as plt
89
from PIL import UnidentifiedImageError # pylint: disable=unused-import
910

@@ -154,7 +155,7 @@ def test_ellipses_image_takes_precedence_over_background(mock_show, tmp_path):
154155

155156
# Test that when both image and background are provided, image takes precedence
156157
# This should not attempt to download background map
157-
import numpy as np
158+
import numpy as np # pylint: disable=import-outside-toplevel
158159

159160
mock_image = np.zeros((100, 100, 3), dtype=np.uint8) # RGB image
160161

@@ -217,7 +218,7 @@ def test_ellipses_background_contextily_not_installed(mock_show):
217218
Mocks the matplotlib.pyplot.show() function to avoid showing the plots.
218219
"""
219220
mock_monte_carlo = MockMonteCarlo(environment=SimpleEnvironment())
220-
from rocketpy.tools import import_optional_dependency as original_import
221+
from rocketpy.tools import import_optional_dependency as original_import # pylint: disable=import-outside-toplevel
221222

222223
# Create a mock function that only raises exception when importing contextily
223224
def mock_import_optional_dependency(name):
@@ -391,8 +392,8 @@ def test_ellipses_background_bounds2img_failure(
391392
List of expected message substrings in the raised exception.
392393
"""
393394
mock_monte_carlo = MockMonteCarlo(environment=SimpleEnvironment())
394-
from rocketpy.tools import import_optional_dependency as original_import
395-
import contextily
395+
from rocketpy.tools import import_optional_dependency as original_import # pylint: disable=import-outside-toplevel
396+
import contextily # pylint: disable=import-outside-toplevel
396397

397398
mock_contextily = MagicMock()
398399
mock_contextily.providers = contextily.providers

0 commit comments

Comments
 (0)