# Path: pythoscope/compat.py
# def all(iterable):
# def any(iterable):
# def sorted(iterable, compare=cmp, key=None):
#     def __init__(self, iterable, key=None):
#     def __iter__(self):
#     def next(self):
#     def _grouper(self, tgtkey):
# def samefile(file1, file2):
# class groupby(object):
# 
# Path: pythoscope/util.py
# def quoted_block(text):
#     return ''.join(["> %s" % line for line in text.splitlines(True)])


import difflib
import re
from nose.tools import assert_equal, assert_not_equal, assert_raises
from pythoscope.compat import set
from pythoscope.util import quoted_block
    "assert_not_raises",
    "assert_single_class",
    "assert_single_function",
    "assert_one_element_and_return"]


def assert_contains(haystack, needle):
    assert needle in haystack,\
           "Expected\n%s\nto contain %r, but it didn't." % (quoted_block(haystack), needle)

def assert_contains_once(haystack, needle):
    repeated = len(re.findall(re.escape(needle), haystack))
    assert repeated == 1, "Expected\n%s\nto contain %r once, but it contained it %d times instead." %\
           (quoted_block(haystack), needle, repeated)

def assert_contains_one_after_another(haystack, needle1, needle2):
    assert re.search(''.join([needle1, '.*', needle2]), haystack, re.DOTALL), \
        "Expected\n%s\nto contain %r and then %r, but it didn't." %\
           (quoted_block(haystack), needle1, needle2)

def assert_doesnt_contain(haystack, needle):
    assert needle not in haystack,\
           "Expected\n%s\nto NOT contain %r, but it did." % (quoted_block(haystack), needle)

def assert_equal_sets(collection1, collection2):
    """Assert that both collections have the same number and set of elements.
    """
    # Checking length of both collections first, so we catch duplicates that
    # appear in one collection and not the other.
    assert_length(collection2, len(collection1))

# Path: pythoscope/compat.py
# def all(iterable):
# def any(iterable):
# def sorted(iterable, compare=cmp, key=None):
#     def __init__(self, iterable, key=None):
#     def __iter__(self):
#     def next(self):
#     def _grouper(self, tgtkey):
# def samefile(file1, file2):
# class groupby(object):
# 
# Path: pythoscope/util.py
# def quoted_block(text):
#     return ''.join(["> %s" % line for line in text.splitlines(True)])


# Path: test/assertions.py
import difflib
import re
from nose.tools import assert_equal, assert_not_equal, assert_raises
from pythoscope.compat import set
from pythoscope.util import quoted_block

    "assert_not_raises",
    "assert_single_class",
    "assert_single_function",
    "assert_one_element_and_return"]


def assert_contains(haystack, needle):
    assert needle in haystack,\
           "Expected\n%s\nto contain %r, but it didn't." % (quoted_block(haystack), needle)

def assert_contains_once(haystack, needle):
    repeated = len(re.findall(re.escape(needle), haystack))
    assert repeated == 1, "Expected\n%s\nto contain %r once, but it contained it %d times instead." %\
           (quoted_block(haystack), needle, repeated)

def assert_contains_one_after_another(haystack, needle1, needle2):
    assert re.search(''.join([needle1, '.*', needle2]), haystack, re.DOTALL), \
        "Expected\n%s\nto contain %r and then %r, but it didn't." %\
           (quoted_block(haystack), needle1, needle2)

def assert_doesnt_contain(haystack, needle):
    assert needle not in haystack,\
           "Expected\n%s\nto NOT contain %r, but it did." % (quoted_block(haystack), needle)

def assert_equal_sets(collection1, collection2):
    """Assert that both collections have the same number and set of elements.
    """
    # Checking length of both collections first, so we catch duplicates that
    # appear in one collection and not the other.
    assert_length(collection2, len(collection1))

    assert_equal(set(collection1), set(collection2))