def test_custom_relative_data_dir(self, chdir_tmp_path, tmp_sub_dir, tmp_relative_sub_dir): "Test using a custom relative data directory." init(DATADIR=tmp_relative_sub_dir) assert get_config().DATADIR == tmp_sub_dir assert get_config().DATADIR.is_absolute()
def test_custom_data_dir(self, tmp_path, wikitext103_schema): "Test to make sure Dataset constructor uses new global data dir if one was supplied earlier to pydax.init." init(DATADIR=tmp_path) assert get_config().DATADIR == tmp_path assert isinstance(get_config().DATADIR, pathlib.Path) wikitext = Dataset(wikitext103_schema, data_dir=tmp_path, mode=Dataset.InitializationMode.LAZY) assert wikitext._data_dir == tmp_path assert isinstance(wikitext._data_dir, pathlib.Path)
def test_custom_configs(self): "Test custom configs." init(update_only=False) # set back everything to default assert dataclasses.asdict(get_config()) == dataclasses.asdict(Config()) new_urls = { 'DATASET_SCHEMA_FILE_URL': 'some/local/file', 'FORMAT_SCHEMA_FILE_URL': 'file://c:/some/other/local/file', 'LICENSE_SCHEMA_FILE_URL': 'http://some/remote/file' } init(update_only=True, **new_urls) for url, val in new_urls.items(): assert getattr(get_config(), url) == val assert get_config().DATADIR == Config.DATADIR
def test_custom_symlink_data_dir(self, tmp_symlink_dir): "Test using a custom symlink data directory. The symlink should not be resolved." init(DATADIR=tmp_symlink_dir) assert get_config().DATADIR == tmp_symlink_dir
def test_default_data_dir(self): "Test default data dir." pydax_data_home = pathlib.Path.home() / '.pydax' / 'data' assert get_config().DATADIR == pydax_data_home assert isinstance(get_config().DATADIR, pathlib.Path)