def __dir__(self) -> List[str]: """Available data providers. :return: List of attributes. """ attributes = [] exclude = BaseDataProvider().__dict__.keys() for a in self.__dict__: if a not in exclude: if a.startswith('_'): attribute = a.replace('_', '', 1) attributes.append(attribute) else: attributes.append(a) return attributes
def __dir__(self) -> List[str]: """Available data providers. The list of result will be used in AbstractField to determine method's class. :return: List of attributes. """ attributes = [] exclude = BaseDataProvider().__dict__.keys() for a in self.__dict__: if a not in exclude: if a.startswith('_'): attribute = a.replace('_', '', 1) attributes.append(attribute) else: attributes.append(a) return attributes
def _bases(self, seed): return BaseDataProvider(seed=seed), BaseDataProvider(seed=seed)
def test_get_current_locale(self, locale): base = BaseDataProvider(locale=locale) assert locale == base.get_current_locale()
def base_data_provider(self): return BaseDataProvider()
def test_load_datafile_raises(self, locale): data_provider = BaseDataProvider(locale=locale) with pytest.raises(FileNotFoundError): data_provider._load_datafile("something.json")
def test_setup_locale_unsupported_locale(self): with pytest.raises(LocaleError): BaseDataProvider(locale="nil")
def test_load_datafile(self, locale, city): data_provider = BaseDataProvider(locale) data_provider._load_datafile("address.json") assert city in data_provider._data["city"]
def test_setup_locale(self, base_data_provider, inp, out): result = BaseDataProvider(locale=inp) assert result.locale == out
def test_pull_raises(self, locale): data_provider = BaseDataProvider(locale=locale) with pytest.raises(FileNotFoundError): data_provider._pull('something.json')
def test_pull(self, locale, city): data_provider = BaseDataProvider(locale) data_provider._pull('address.json') assert city in data_provider._data['city']
def test_setup_locale_unsupported_locale(self): with pytest.raises(UnsupportedLocale): BaseDataProvider(locale='nil')
def seeded_base_data_provider(): return BaseDataProvider(seed=42)