diff --git a/tests/data/test_converter.py b/tests/data/test_converter.py index ebee4a3be..49a16f7c9 100644 --- a/tests/data/test_converter.py +++ b/tests/data/test_converter.py @@ -323,18 +323,17 @@ def test_trades_dict_to_list(fetch_trades_result): assert t[6] == fetch_trades_result[i]['cost'] -def test_convert_trades_format(default_conf, testdatadir, tmpdir): - tmpdir1 = Path(tmpdir) - files = [{'old': tmpdir1 / "XRP_ETH-trades.json.gz", - 'new': tmpdir1 / "XRP_ETH-trades.json"}, - {'old': tmpdir1 / "XRP_OLD-trades.json.gz", - 'new': tmpdir1 / "XRP_OLD-trades.json"}, +def test_convert_trades_format(default_conf, testdatadir, tmp_path): + files = [{'old': tmp_path / "XRP_ETH-trades.json.gz", + 'new': tmp_path / "XRP_ETH-trades.json"}, + {'old': tmp_path / "XRP_OLD-trades.json.gz", + 'new': tmp_path / "XRP_OLD-trades.json"}, ] for file in files: copyfile(testdatadir / file['old'].name, file['old']) assert not file['new'].exists() - default_conf['datadir'] = tmpdir1 + default_conf['datadir'] = tmp_path convert_trades_format(default_conf, convert_from='jsongz', convert_to='json', erase=False) @@ -362,16 +361,15 @@ def test_convert_trades_format(default_conf, testdatadir, tmpdir): (['UNITTEST_USDT_USDT-1h-mark', 'XRP_USDT_USDT-1h-mark'], CandleType.MARK), (['XRP_USDT_USDT-1h-futures'], CandleType.FUTURES), ]) -def test_convert_ohlcv_format(default_conf, testdatadir, tmpdir, file_base, candletype): - tmpdir1 = Path(tmpdir) +def test_convert_ohlcv_format(default_conf, testdatadir, tmp_path, file_base, candletype): prependix = '' if candletype == CandleType.SPOT else 'futures/' files_orig = [] files_temp = [] files_new = [] for file in file_base: file_orig = testdatadir / f"{prependix}{file}.feather" - file_temp = tmpdir1 / f"{prependix}{file}.feather" - file_new = tmpdir1 / f"{prependix}{file}.json.gz" + file_temp = tmp_path / f"{prependix}{file}.feather" + file_new = tmp_path / f"{prependix}{file}.json.gz" IDataHandler.create_dir_if_needed(file_temp) copyfile(file_orig, file_temp) @@ -379,7 +377,7 @@ def test_convert_ohlcv_format(default_conf, testdatadir, tmpdir, file_base, cand files_temp.append(file_temp) files_new.append(file_new) - default_conf['datadir'] = tmpdir1 + default_conf['datadir'] = tmp_path default_conf['candle_types'] = [candletype] if candletype == CandleType.SPOT: @@ -445,30 +443,29 @@ def test_reduce_dataframe_footprint(): assert df2['close_copy'].dtype == np.float32 -def test_convert_trades_to_ohlcv(testdatadir, tmpdir, caplog): - tmpdir1 = Path(tmpdir) +def test_convert_trades_to_ohlcv(testdatadir, tmp_path, caplog): pair = 'XRP/ETH' - file1 = tmpdir1 / 'XRP_ETH-1m.feather' - file5 = tmpdir1 / 'XRP_ETH-5m.feather' - filetrades = tmpdir1 / 'XRP_ETH-trades.json.gz' + file1 = tmp_path / 'XRP_ETH-1m.feather' + file5 = tmp_path / 'XRP_ETH-5m.feather' + filetrades = tmp_path / 'XRP_ETH-trades.json.gz' copyfile(testdatadir / file1.name, file1) copyfile(testdatadir / file5.name, file5) copyfile(testdatadir / filetrades.name, filetrades) # Compare downloaded dataset with converted dataset - dfbak_1m = load_pair_history(datadir=tmpdir1, timeframe="1m", pair=pair) - dfbak_5m = load_pair_history(datadir=tmpdir1, timeframe="5m", pair=pair) + dfbak_1m = load_pair_history(datadir=tmp_path, timeframe="1m", pair=pair) + dfbak_5m = load_pair_history(datadir=tmp_path, timeframe="5m", pair=pair) tr = TimeRange.parse_timerange('20191011-20191012') convert_trades_to_ohlcv([pair], timeframes=['1m', '5m'], data_format_trades='jsongz', - datadir=tmpdir1, timerange=tr, erase=True) + datadir=tmp_path, timerange=tr, erase=True) assert log_has("Deleting existing data for pair XRP/ETH, interval 1m.", caplog) # Load new data - df_1m = load_pair_history(datadir=tmpdir1, timeframe="1m", pair=pair) - df_5m = load_pair_history(datadir=tmpdir1, timeframe="5m", pair=pair) + df_1m = load_pair_history(datadir=tmp_path, timeframe="1m", pair=pair) + df_5m = load_pair_history(datadir=tmp_path, timeframe="5m", pair=pair) assert_frame_equal(dfbak_1m, df_1m, check_exact=True) assert_frame_equal(dfbak_5m, df_5m, check_exact=True) @@ -477,5 +474,5 @@ def test_convert_trades_to_ohlcv(testdatadir, tmpdir, caplog): convert_trades_to_ohlcv(['NoDatapair'], timeframes=['1m', '5m'], data_format_trades='jsongz', - datadir=tmpdir1, timerange=tr, erase=True) + datadir=tmp_path, timerange=tr, erase=True) assert log_has(msg, caplog) diff --git a/tests/test_binance_mig.py b/tests/test_binance_mig.py index dc89a1ae7..f1694bfc8 100644 --- a/tests/test_binance_mig.py +++ b/tests/test_binance_mig.py @@ -10,7 +10,7 @@ from freqtrade.util.binance_mig import migrate_binance_futures_data, migrate_bin from tests.conftest import create_mock_trades_usdt, log_has -def test_binance_mig_data_conversion(default_conf_usdt, tmpdir, testdatadir): +def test_binance_mig_data_conversion(default_conf_usdt, tmp_path, testdatadir): # call doing nothing (spot mode) migrate_binance_futures_data(default_conf_usdt) @@ -18,7 +18,7 @@ def test_binance_mig_data_conversion(default_conf_usdt, tmpdir, testdatadir): pair_old = 'XRP_USDT' pair_unified = 'XRP_USDT_USDT' futures_src = testdatadir / 'futures' - futures_dst = tmpdir / 'futures' + futures_dst = tmp_path / 'futures' futures_dst.mkdir() files = [ '-1h-mark.feather', @@ -32,7 +32,7 @@ def test_binance_mig_data_conversion(default_conf_usdt, tmpdir, testdatadir): fn_after = futures_dst / f'{pair_old}{file}' shutil.copy(futures_src / f'{pair_unified}{file}', fn_after) - default_conf_usdt['datadir'] = Path(tmpdir) + default_conf_usdt['datadir'] = tmp_path # Migrate files to unified namings migrate_binance_futures_data(default_conf_usdt) diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 3f2fb0669..bbd299e6a 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -104,8 +104,8 @@ def test_load_config_file_error_range(default_conf, mocker, caplog) -> None: assert x == '' -def test_load_file_error(tmpdir): - testpath = Path(tmpdir) / 'config.json' +def test_load_file_error(tmp_path): + testpath = tmp_path / 'config.json' with pytest.raises(OperationalException, match=r"File .* not found!"): load_file(testpath) @@ -1145,7 +1145,7 @@ def test_pairlist_resolving_with_config_pl_not_exists(mocker, default_conf): configuration.get_config() -def test_pairlist_resolving_fallback(mocker, tmpdir): +def test_pairlist_resolving_fallback(mocker, tmp_path): mocker.patch.object(Path, "exists", MagicMock(return_value=True)) mocker.patch.object(Path, "open", MagicMock(return_value=MagicMock())) mocker.patch("freqtrade.configuration.configuration.load_file", @@ -1164,7 +1164,7 @@ def test_pairlist_resolving_fallback(mocker, tmpdir): assert config['pairs'] == ['ETH/BTC', 'XRP/BTC'] assert config['exchange']['name'] == 'binance' - assert config['datadir'] == Path(tmpdir) / "user_data/data/binance" + assert config['datadir'] == tmp_path / "user_data/data/binance" @pytest.mark.parametrize("setting", [ diff --git a/tests/test_log_setup.py b/tests/test_log_setup.py index bd3399615..47b93c947 100644 --- a/tests/test_log_setup.py +++ b/tests/test_log_setup.py @@ -75,11 +75,11 @@ def test_set_loggers_syslog(): @pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows") -def test_set_loggers_Filehandler(tmpdir): +def test_set_loggers_Filehandler(tmp_path): logger = logging.getLogger() orig_handlers = logger.handlers logger.handlers = [] - logfile = Path(tmpdir) / 'ft_logfile.log' + logfile = tmp_path / 'ft_logfile.log' config = {'verbosity': 2, 'logfile': str(logfile), }