From 6a893a321ae8ba379ec7af2444c7aff313c8095f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Sun, 6 May 2018 03:01:59 +0200 Subject: [PATCH] more retries for a unit test --- _unittests/ut_finance/test_stock_url_yahoo.py | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/_unittests/ut_finance/test_stock_url_yahoo.py b/_unittests/ut_finance/test_stock_url_yahoo.py index 3fec23fc..55d350b0 100644 --- a/_unittests/ut_finance/test_stock_url_yahoo.py +++ b/_unittests/ut_finance/test_stock_url_yahoo.py @@ -48,13 +48,23 @@ def test_download_stock_yahoo(self): self._testMethodName, OutputPrint=__name__ == "__main__") cache = get_temp_folder(__file__, "temp_url_yahoo") - stock = StockPrices("^FCHI", folder=cache, url="yahoo", - begin=datetime.datetime(2014, 1, 15)) - df = stock.dataframe - dmin = df.Date.min() - self.assertIn("2014", str(dmin)) - if "^FCHI.2014-01-15" not in stock.url_: - raise AssertionError(stock.url_) + exc = [] + for n in range(0, 4): + stock = StockPrices("^FCHI", folder=cache, url="yahoo", + begin=datetime.datetime(2014, 1, 15)) + df = stock.dataframe + dmin, dmax = df.Date.min(), df.Date.max() + try: + self.assertIn("2014", str(dmin)) + self.assertNotEqual(dmin, dmax) + if "^FCHI.2014-01-15" not in stock.url_: + raise AssertionError(stock.url_) + return + except AssertionError as e: + exc.append(e) + if len(exc) > 0: + e = exc[0] + raise AssertionError('nb tries={0}'.format(len(exc))) from e if __name__ == "__main__":