File: conftest.py

package info (click to toggle)
python-docker 1.7.2-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 644 kB
  • sloc: python: 8,258; makefile: 7; sh: 3
file content (31 lines) | stat: -rw-r--r-- 838 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
21
22
23
24
25
26
27
28
29
30
31
from __future__ import print_function

import json
import sys
import warnings

import docker.errors
import pytest

from ..helpers import BUSYBOX
from ..helpers import docker_client


@pytest.fixture(autouse=True, scope='session')
def setup_test_session():
    warnings.simplefilter('error')
    c = docker_client()
    try:
        c.inspect_image(BUSYBOX)
    except docker.errors.NotFound:
        print("\npulling {0}".format(BUSYBOX), file=sys.stderr)
        for data in c.pull(BUSYBOX, stream=True):
            data = json.loads(data.decode('utf-8'))
            status = data.get("status")
            progress = data.get("progress")
            detail = "{0} - {1}".format(status, progress)
            print(detail, file=sys.stderr)

        # Double make sure we now have busybox
        c.inspect_image(BUSYBOX)
    c.close()