File: test_utils.py

package info (click to toggle)
python-rfc6555 0.0~git20190913.1a181b4-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 148 kB
  • sloc: python: 339; makefile: 4
file content (17 lines) | stat: -rw-r--r-- 380 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import pytest
import socket


def _check_network():
    sock = None
    try:
        sock = socket.create_connection(('www.google.com', 80))
        sock.close()
        return True
    except Exception:
        if sock:
            sock.close()
        return False


requires_network = pytest.mark.skipif(not _check_network(), reason='This test requires a network connection.')