MCPcopy Create free account
hub / github.com/ccxt/ccxt / test_method

Method test_method

python/ccxt/test/tests_sync.py:187–233  ·  view source on GitHub ↗
(self, method_name, exchange, args, is_public)

Source from the content-addressed store, hash-verified

185 return message + res
186
187 def test_method(self, method_name, exchange, args, is_public):
188 # todo: temporary skip for c#
189 if 'OrderBook' in method_name and self.ext == 'cs':
190 exchange.options['checksum'] = False
191 # todo: temporary skip for php
192 if 'OrderBook' in method_name and self.ext == 'php':
193 return True
194 skipped_properties_for_method = self.get_skips(exchange, method_name)
195 is_load_markets = (method_name == 'loadMarkets')
196 is_fetch_currencies = (method_name == 'fetchCurrencies')
197 is_proxy_test = (method_name == self.proxy_test_file_name)
198 is_constructor_test = (method_name == 'afterConstruct')
199 is_feature_test = (method_name == 'features')
200 # if this is a private test, and the implementation was already tested in public, then no need to re-test it in private test (exception is fetchCurrencies, because our approach in base exchange)
201 if not is_public and (method_name in self.checked_public_tests) and not is_fetch_currencies:
202 return True
203 skip_message = None
204 supported_by_exchange = (method_name in exchange.has) and exchange.has[method_name]
205 if not is_load_markets and (len(self.only_specific_tests) > 0 and not exchange.in_array(method_name, self.only_specific_tests)):
206 skip_message = '[INFO] IGNORED_TEST'
207 elif not is_load_markets and not supported_by_exchange and not is_proxy_test and not is_feature_test and not is_constructor_test:
208 skip_message = '[INFO] UNSUPPORTED_TEST' # keep it aligned with the longest message
209 elif isinstance(skipped_properties_for_method, str):
210 skip_message = '[INFO] SKIPPED_TEST'
211 elif not (method_name in self.test_files):
212 skip_message = '[INFO] UNIMPLEMENTED_TEST'
213 # exceptionally for `loadMarkets` call, we call it before it's even checked for "skip" as we need it to be called anyway (but can skip "test.loadMarket" for it)
214 if is_load_markets:
215 exchange.load_markets(True)
216 name = exchange.id
217 if skip_message:
218 if self.info:
219 dump(self.add_padding(skip_message, 25), name, method_name)
220 return True
221 if self.info:
222 args_stringified = '(' + exchange.json(args) + ')' # args.join() breaks when we provide a list of symbols or multidimensional array; "args.toString()" breaks bcz of "array to string conversion"
223 dump(self.add_padding('[INFO] TESTING', 25), name, method_name, args_stringified)
224 if is_sync():
225 call_method_sync(self.test_files, method_name, exchange, skipped_properties_for_method, args)
226 else:
227 call_method(self.test_files, method_name, exchange, skipped_properties_for_method, args)
228 if self.info:
229 dump(self.add_padding('[INFO] TESTING DONE', 25), name, method_name)
230 # add to the list of successed tests
231 if is_public:
232 self.checked_public_tests[method_name] = True
233 return True
234
235 def get_skips(self, exchange, method_name):
236 final_skips = {}

Callers 2

test_safeMethod · 0.95
test_proxiesMethod · 0.95

Calls 9

get_skipsMethod · 0.95
add_paddingMethod · 0.95
dumpFunction · 0.90
is_syncFunction · 0.90
call_method_syncFunction · 0.90
call_methodFunction · 0.90
in_arrayMethod · 0.80
load_marketsMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected