def __init__(self, symbols=None, **kwargs): """ Initialize the class Parameters ---------- symbols : string, array-like object (list, tuple, Series), or DataFrame Desired symbols for retrieval output_format: str, default 'json', optional Desired output format (json or pandas) kwargs: Additional request options (see base class) """ if symbols: self.symbols = _handle_lists(symbols) if len(self.symbols) > self.symbol_limit: raise ValueError("At most " + str(self.symbol_limit) + "symbols may be entered at once.") else: if self.symbol_required: raise ValueError("Please input a symbol or list of symbols.") self.symbols = [] super(Market, self).__init__(**kwargs)
def test_handle_lists_err(self, mult): with pytest.raises(ValueError): _handle_lists(mult, mult=False)
def test_handle_lists_mult(self, mult): assert _handle_lists(mult) == [1, 2, 3]
def test_handle_lists_sing(self, single): assert _handle_lists(single, mult=False) == single assert _handle_lists(single) == [single]