<commit_before>from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from builtins import *  # pylint:disable=redefined-builtin,unused-wildcard-import,wildcard-import,wrong-import-order
import random
import timeit

import cv2
import numpy
import pytest

import stbt
from _stbt import cv2_compat
from _stbt.match import _merge_regions
from tests.test_core import _find_file


requires_opencv_3 = pytest.mark.skipif(cv2_compat.version < [3, 0, 0],
                                       reason="Requires OpenCV 3")


def mp(match_method=stbt.MatchMethod.SQDIFF, match_threshold=None, **kwargs):
    if match_threshold is None and match_method != stbt.MatchMethod.SQDIFF:
        match_threshold = 0.8
    return stbt.MatchParameters(match_method, match_threshold, **kwargs)


def black(width=1280, height=720, value=0):
    return numpy.ones((height, width, 3), dtype=numpy.uint8) * value


def test_that_matchresult_image_matches_template_passed_to_match():
    assert stbt.match("black.png", frame=black()).image == "black.png"


def test_that_matchresult_str_image_matches_template_passed_to_match():
    assert "image=\'black.png\'" in str(stbt.match("black.png", frame=black()))
<commit_msg>Python3: test_that_matchresult_str...: Handle Python 2 & 3 formatting<commit_after>from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from builtins import *  # pylint:disable=redefined-builtin,unused-wildcard-import,wildcard-import,wrong-import-order
import random
import re
import timeit

import cv2
import numpy
import pytest

import stbt
from _stbt import cv2_compat
from _stbt.match import _merge_regions
from tests.test_core import _find_file


requires_opencv_3 = pytest.mark.skipif(cv2_compat.version < [3, 0, 0],
                                       reason="Requires OpenCV 3")


def mp(match_method=stbt.MatchMethod.SQDIFF, match_threshold=None, **kwargs):
    if match_threshold is None and match_method != stbt.MatchMethod.SQDIFF:
        match_threshold = 0.8
    return stbt.MatchParameters(match_method, match_threshold, **kwargs)


def black(width=1280, height=720, value=0):
    return numpy.ones((height, width, 3), dtype=numpy.uint8) * value


def test_that_matchresult_image_matches_template_passed_to_match():
    assert stbt.match("black.png", frame=black()).image == "black.png"


def test_that_matchresult_str_image_matches_template_passed_to_match():
    assert re.search(r"image=u?'black.png'",
                     str(stbt.match("black.png", frame=black())))

{'fraction_non_alphanumeric': 0.09233644859813084, 'fraction_numerical': 0.016074766355140185, 'mean_word_length': 4.973214285714286, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2443213', 'n_tokens_mistral': 880, 'n_tokens_neox': 831, 'n_words': 191}