Convert CryptoToFiatConverter into a Singleton

Result in a speed up of the unittest from 60s to 4s

Because it cost time to load Pymarketcap() every time we create
a CryptoToFiatConverter, it worth it to change it into a
Singleton.
This commit is contained in:
Gerald Lonlas
2018-01-21 15:32:49 -08:00
parent 408f120612
commit 28b1ecb109
4 changed files with 21 additions and 24 deletions

View File

@@ -116,9 +116,9 @@ def test_fiat_convert_get_price(mocker):
assert fiat_convert._pairs[0]._expiration is not expiration
def test_fiat_convert_without_network(mocker):
pymarketcap = MagicMock(side_effect=ImportError('Oh boy, you have no network!'))
mocker.patch('freqtrade.fiat_convert.Pymarketcap', pymarketcap)
def test_fiat_convert_without_network():
# Because CryptoToFiatConverter is a Singleton we reset the value of _coinmarketcap
CryptoToFiatConverter._coinmarketcap = None
fiat_convert = CryptoToFiatConverter()
assert fiat_convert._coinmarketcap is None