From a8a185eca86883a71580a68e6030c760e5cbd8d5 Mon Sep 17 00:00:00 2001 From: Gui-FernandesBR Date: Fri, 19 Apr 2024 12:08:58 -0400 Subject: [PATCH] TST: Fix tests with Environment class after exponential_backoff decorator was used --- tests/fixtures/environment/environment_fixtures.py | 5 +++-- tests/test_environment.py | 10 ++-------- tests/unit/test_environment.py | 2 +- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/fixtures/environment/environment_fixtures.py b/tests/fixtures/environment/environment_fixtures.py index 8949f9973..851be3203 100644 --- a/tests/fixtures/environment/environment_fixtures.py +++ b/tests/fixtures/environment/environment_fixtures.py @@ -1,6 +1,7 @@ from datetime import datetime, timedelta import pytest + from rocketpy import Environment, EnvironmentAnalysis @@ -54,8 +55,8 @@ def env_analysis(): EnvironmentAnalysis """ env_analysis = EnvironmentAnalysis( - start_date=datetime.datetime(2019, 10, 23), - end_date=datetime.datetime(2021, 10, 23), + start_date=datetime(2019, 10, 23), + end_date=datetime(2021, 10, 23), latitude=39.3897, longitude=-8.28896388889, start_hour=6, diff --git a/tests/test_environment.py b/tests/test_environment.py index 5fa0e2c45..7349d512b 100644 --- a/tests/test_environment.py +++ b/tests/test_environment.py @@ -1,5 +1,4 @@ import datetime -import time from unittest.mock import patch import pytest @@ -64,13 +63,8 @@ def test_wyoming_sounding_atmosphere(mock_show, example_plain_env): # "file" option, instead of receiving the URL as a string. URL = "http://weather.uwyo.edu/cgi-bin/sounding?region=samer&TYPE=TEXT%3ALIST&YEAR=2019&MONTH=02&FROM=0500&TO=0512&STNM=83779" # give it at least 5 times to try to download the file - for i in range(5): - try: - example_plain_env.set_atmospheric_model(type="wyoming_sounding", file=URL) - break - except: - time.sleep(1) # wait 1 second before trying again - pass + example_plain_env.set_atmospheric_model(type="wyoming_sounding", file=URL) + assert example_plain_env.all_info() == None assert abs(example_plain_env.pressure(0) - 93600.0) < 1e-8 assert ( diff --git a/tests/unit/test_environment.py b/tests/unit/test_environment.py index ac25533eb..8d676f426 100644 --- a/tests/unit/test_environment.py +++ b/tests/unit/test_environment.py @@ -1,10 +1,10 @@ +import json import os import numpy as np import numpy.ma as ma import pytest import pytz -import json from rocketpy import Environment