From 019de17f56620e1c0cfe9aa9f88b2ab157635c47 Mon Sep 17 00:00:00 2001 From: MARCHAND MANON Date: Thu, 11 Jul 2024 12:53:22 +0200 Subject: [PATCH] refactor: avoid a bit of list duplication --- pyproject.toml | 4 ++++ src/test/__init__.py | 0 src/test/test_aladin.py | 32 +++--------------------------- src/test/test_coordinate_parser.py | 5 +++-- 4 files changed, 10 insertions(+), 31 deletions(-) create mode 100644 src/test/__init__.py diff --git a/pyproject.toml b/pyproject.toml index 97031efd..0c6201df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,5 +51,9 @@ ignore = ["ISC001", "ANN101", "D203", "D213", "D100", "D105"] [tool.ruff.lint.pydocstyle] convention = "numpy" +[tool.ruff.lint.per-file-ignores] +# D104: Missing docstring in public package +"__init__.py" = ["D104"] + [tool.ruff.format] docstring-code-format = false diff --git a/src/test/__init__.py b/src/test/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/test/test_aladin.py b/src/test/test_aladin.py index d584053a..749a12f0 100644 --- a/src/test/test_aladin.py +++ b/src/test/test_aladin.py @@ -5,6 +5,8 @@ from ipyaladin import Aladin from ipyaladin.coordinate_parser import parse_coordinate_string +from .test_coordinate_parser import test_is_coordinate_string_values + aladin = Aladin() @@ -15,35 +17,7 @@ def mock_sesame(monkeypatch: Callable) -> None: monkeypatch.setattr(SkyCoord, "from_name", lambda _: SkyCoord(0, 0, unit="deg")) -test_aladin_string_target = [ - "M 31", - "sgr a*", - "α Centauri", # noqa RUF001 - "* 17 Com", - "1:12:43.2 31:12:43", - "1:12:43.2 +31:12:43", - "1:12:43.2 -31:12:43", - "1 12 43.2 31 12 43", - "1 12 43.2 +31 12 43", - "1 12 43.2 -31 12 43", - "1h12m43.2s 1d12m43s", - "1h12m43.2s +1d12m43s", - "1h12m43.2s -1d12m43s", - "42.67 25.48", - "42.67 +25.48", - "42.67 -25.48", - "0 0", - "J42.67 25.48", - "G42.67 25.48", - "B42.67 25.48", - "J12 30 45 +45 30 15", - "J03 15 20 -10 20 30", - "G120.5 -45.7", - "G90 0", - "B60 30", - "B120 -45", - "Galactic Center", -] +test_aladin_string_target, _ = zip(*test_is_coordinate_string_values) @pytest.mark.parametrize("target", test_aladin_string_target) diff --git a/src/test/test_coordinate_parser.py b/src/test/test_coordinate_parser.py index 549a7fb2..9282f2b0 100644 --- a/src/test/test_coordinate_parser.py +++ b/src/test/test_coordinate_parser.py @@ -11,6 +11,8 @@ test_is_coordinate_string_values = [ ("M 31", False), ("sgr a*", False), + ("α Centauri", False), # noqa RUF001 + ("* 17 Com", False), ("1:12:43.2 31:12:43", True), ("1:12:43.2 +31:12:43", True), ("1:12:43.2 -31:12:43", True), @@ -24,11 +26,10 @@ ("42.67 +25.48", True), ("42.67 -25.48", True), ("0 0", True), + ("J12 30 45 +45 30 15", True), ("J42.67 25.48", True), ("G42.67 25.48", True), ("B42.67 25.48", True), - ('17h 45m 40.0409s -29° 00′ 28.118"', True), # noqa RUF001 - ("17h 45m 40.0409s -29° 00' 28.118\"", True), ("Galactic Center", False), ]