Skip to content

Commit 2b31b42

Browse files
thc1006Gui-FernandesBR
authored andcommitted
TST: cover the branch a first run actually takes
samefile needs both files to exist, and every case here wrote one first, so the resolved-path fallback that a run with no logs yet goes through was never exercised. Replacing it with False leaves the new test red. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
1 parent 7efa092 commit 2b31b42

9 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎monte_carlo_test.errors.txt‎

Whitespace-only changes.

‎monte_carlo_test.inputs.txt‎

Whitespace-only changes.

‎monte_carlo_test.outputs.txt‎

Whitespace-only changes.

‎rocketpy/environment/environment.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import os
66
import re
77
import warnings
8-
from collections import namedtuple
98
from collections.abc import Mapping
9+
from collections import namedtuple
1010
from datetime import datetime
1111

1212
import netCDF4

‎tests/acceptance/test_defiance_rocket.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from rocketpy.motors import CylindricalTank, Fluid, HybridMotor
77
from rocketpy.motors.tank import MassFlowRateBasedTank
88

9+
910
MEASURED_APOGEE_AGL = 9308.32
1011
MAX_RELATIVE_APOGEE_ERROR = 0.01
1112
REFERENCE_MAX_SPEED = 444.24

‎tests/unit/environment/test_environment.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import os
33
from datetime import datetime
44

5-
import netCDF4
65
import numpy as np
76
import numpy.testing as npt
7+
import netCDF4
88
import pytest
99
import pytz
1010

‎tests/unit/simulation/test_monte_carlo.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,3 +763,19 @@ def test_a_newline_in_the_separators_is_refused_too(tmp_path):
763763
def test_export_options_that_keep_one_line_are_left_alone(tmp_path, harmless):
764764
"""Only what puts a newline inside a record is refused."""
765765
_refuse_logs_this_run_cannot_write(*_three_logs(tmp_path), harmless)
766+
767+
768+
def test_two_names_for_a_file_that_does_not_exist_yet_are_still_one_file(tmp_path):
769+
"""``samefile`` needs both to exist, and a first run has created neither.
770+
771+
Every other case here writes the file first, so the resolved-path branch
772+
that a first run actually takes was never exercised.
773+
"""
774+
(tmp_path / "sub").mkdir()
775+
missing = str(tmp_path / "run.inputs.txt")
776+
same_by_another_name = str(tmp_path / "sub" / ".." / "run.inputs.txt")
777+
errors = str(tmp_path / "run.errors.txt")
778+
779+
assert not pathlib.Path(missing).exists()
780+
with pytest.raises(ValueError, match="same file"):
781+
_refuse_logs_this_run_cannot_write(missing, same_by_another_name, errors)

‎tests/unit/stochastic/test_stochastic_parachute.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import numpy as np
44
import pytest
55

6-
from rocketpy.rocket.parachute import Parachute
76
from rocketpy.stochastic import StochasticParachute
7+
from rocketpy.rocket.parachute import Parachute
88

99

1010
def test_stochastic_parachute_create_object(stochastic_main_parachute):

‎tests/unit/test_tools.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
tuple_handler,
2323
)
2424

25+
2526
WEB_MERCATOR_EARTH_RADIUS = 6378137.0
2627

2728

0 commit comments

Comments
 (0)