dep8b_no_network.py

import socket
import pytest
attempts=[]
def deny(*args,**kwargs):
    attempts.append('network')
    raise AssertionError('DEP8-b offline gate forbids network')
socket.socket.connect=deny
socket.getaddrinfo=deny
@pytest.fixture(autouse=True)
def record_attempts():
    before=len(attempts)
    yield
    assert len(attempts)==before, 'network was attempted during offline gate'
def pytest_sessionfinish(session, exitstatus):
    print('DEP8-b network attempts:', len(attempts))
    if attempts:
        session.exitstatus=1
← All docsView source on GitHub →