Project

General

Profile

« Previous | Next » 

Revision 61f0aa75

Added by koszko over 1 year ago

support piggybacking on APT packages

View differences:

conftest.py
7 7
import sys
8 8
from pathlib import Path
9 9

  
10
import pytest
11

  
10 12
here = Path(__file__).resolve().parent
11 13
sys.path.insert(0, str(here / 'src'))
14

  
15
@pytest.fixture(autouse=True)
16
def no_requests(monkeypatch):
17
    """Remove requests.sessions.Session.request for all tests."""
18
    monkeypatch.delattr('requests.sessions.Session.request')
19

  
20
@pytest.fixture
21
def mock_subprocess_run(monkeypatch, request):
22
    """
23
    Temporarily replace subprocess.run() with a function supplied through pytest
24
    marker 'subprocess_run'.
25

  
26
    The marker excepts 2 arguments:
27
    * the module inside which the subprocess attribute should be mocked and
28
    * a run() function to use.
29
    """
30
    where, mocked_run = request.node.get_closest_marker('subprocess_run').args
31

  
32
    class MockedSubprocess:
33
        """Minimal mocked version of the subprocess module."""
34
        run = mocked_run
35

  
36
    monkeypatch.setattr(where, 'subprocess', MockedSubprocess)

Also available in: Unified diff