# Image-based testing borrowed from vispy

"""
Procedure for unit-testing with images:

1. Run unit tests at least once; this initializes a git clone of
   pyqtgraph/test-data in ~/.pyqtgraph.

2. Run individual test scripts with the PYQTGRAPH_AUDIT environment variable set:

       $ PYQTGRAPH_AUDIT=1 python pyqtgraph/graphicsItems/tests/test_PlotCurveItem.py

   Any failing tests will
   display the test results, standard image, and the differences between the
   two. If the test result is bad, then press (f)ail. If the test result is
   good, then press (p)ass and the new image will be saved to the test-data
   directory.

3. After adding or changing test images, create a new commit:

        $ cd ~/.pyqtgraph/test-data
        $ git add ...
        $ git commit -a

4. Look up the most recent tag name from the `testDataTag` global variable
   below. Increment the tag name by 1 and create a new tag in the test-data
   repository:

        $ git tag test-data-NNN
        $ git push --tags origin master

    This tag is used to ensure that each pyqtgraph commit is linked to a specific
    commit in the test-data repository. This makes it possible to push new
    commits to the test-data repository without interfering with existing
    tests, and also allows unit tests to continue working on older pyqtgraph
    versions.

"""


# This is the name of a tag in the test-data repository that this version of
# pyqtgraph should be tested against. When adding or changing test images,
# create and push a new tag and update this variable.
testDataTag = 'test-data-3'


import time
import os
import sys
import inspect
import base64
import subprocess as sp
import numpy as np

if sys.version[0] >= '3':
    import http.client as httplib
    import urllib.parse as urllib
else:
    import httplib
    import urllib
from ..Qt import QtGui, QtCore