astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v5.2.1 »
- Configuration System (`astropy.config`) »
- set_temp_config

# set_temp_config

class astropy.config.set_temp_config(path=None, delete=False)

  Bases: `_SetTempPath`

  Context manager to set a temporary path for the Astropy config, primarily for use with testing.

  If the path set by this context manager does not already exist it will be created, if possible.

  This may also be used as a decorator on a function to set the config path just within that function.

  Parameters:
    path `python:str`, optional

      The directory (which must exist) in which to find the Astropy config files, or create them if they do not already exist. If None, this restores the config path to the user’s default config path as returned by `get_config_dir` as though this context manager were not in effect (this is useful for testing). In this case the `delete` argument is always ignored.

    delete bool, optional

      If True, cleans up the temporary directory after exiting the temp context (default: False).