From d06d29da2f9e89d96b4c4ea1be1f30cb609c91d0 Mon Sep 17 00:00:00 2001 From: Bijaya Kumar Tiadi <89034485+BijayaKumarTiadi@users.noreply.github.com> Date: Fri, 21 Mar 2025 23:48:03 +0530 Subject: [PATCH] Update test_plot_data.py some optimization --- tests/test_plot_data.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/test_plot_data.py b/tests/test_plot_data.py index 32bdb060..9e368648 100644 --- a/tests/test_plot_data.py +++ b/tests/test_plot_data.py @@ -1,5 +1,4 @@ from pathlib import Path - import pandas as pd import pytest @@ -8,28 +7,28 @@ @pytest.fixture def sample_csv(tmp_path: Path) -> Path: - """Create a sample CSV file for testing.""" - df = pd.DataFrame({"x": [1.0, 2.0, 3.0, 4.0, 5.0], "y": [2.0, 4.0, 6.0, 8.0, 10.0]}) + """Creates and returns a sample CSV file for testing.""" file_path = tmp_path / "test.csv" + df = pd.DataFrame({"x": range(1, 6), "y": [2 * i for i in range(1, 6)]}) df.to_csv(file_path, index=False) return file_path def test_read_csv_data(sample_csv: Path) -> None: - """Test reading data from CSV file.""" + """Tests reading data from a CSV file.""" x_data, y_data = read_csv_data(sample_csv, "x", "y") - assert x_data == [1.0, 2.0, 3.0, 4.0, 5.0] - assert y_data == [2.0, 4.0, 6.0, 8.0, 10.0] + assert x_data == [1, 2, 3, 4, 5] + assert y_data == [2, 4, 6, 8, 10] def test_create_plot() -> None: - """Test plot creation.""" - x_data = [1.0, 2.0, 3.0] - y_data = [2.0, 4.0, 6.0] + """Tests plot creation and verifies labels and title.""" + x_data, y_data = [1, 2, 3], [2, 4, 6] fig = create_plot(x_data, y_data, "X", "Y", "Test Plot") + assert fig is not None - # Basic check that the figure contains the expected elements ax = fig.axes[0] + assert ax.get_xlabel() == "X" assert ax.get_ylabel() == "Y" assert ax.get_title() == "Test Plot"