File: conftest.py

package info (click to toggle)
astroquery 0.4.11%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,576 kB
  • sloc: python: 53,596; xml: 36,604; makefile: 140; ansic: 69
file content (20 lines) | stat: -rw-r--r-- 566 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
from pathlib import Path

import pytest


@pytest.fixture(autouse=True)
def tmp_doctest_path(request, tmp_path):
    """Run doctests in isolated temp dir so outputs do not end up in repo"""
    # Trigger ONLY for doctestplus
    doctest_plugin = request.config.pluginmanager.getplugin("doctestplus")
    if isinstance(request.node.parent, doctest_plugin._doctest_textfile_item_cls):
        start_path = Path.cwd()
        os.chdir(tmp_path)
        try:
            yield tmp_path
        finally:
            os.chdir(start_path)
    else:
        yield