# Path: snapshottest/snapshot.py
# class Snapshot(OrderedDict):
#     pass
# 
# Path: snapshottest/formatter.py
# class Formatter(object):
#     formatters = default_formatters()
# 
#     def __init__(self, imports=None):
#         self.htchar = " " * 4
#         self.lfchar = "\n"
#         self.indent = 0
#         self.imports = imports
# 
#     def __call__(self, value, **args):
#         return self.format(value, self.indent)
# 
#     def format(self, value, indent):
#         formatter = self.get_formatter(value)
#         for module, import_name in formatter.get_imports():
#             self.imports[module].add(import_name)
#         return formatter.format(value, indent, self)
# 
#     def normalize(self, value):
#         formatter = self.get_formatter(value)
#         return formatter.normalize(value, self)
# 
#     @staticmethod
#     def get_formatter(value):
#         for formatter in Formatter.formatters:
#             if formatter.can_format(value):
#                 return formatter
# 
#         # This should never happen as GenericFormatter is registered by default.
#         raise RuntimeError("No formatter found for value")
# 
#     @staticmethod
#     def register_formatter(formatter):
#         Formatter.formatters.insert(0, formatter)
# 
# Path: snapshottest/error.py
# class SnapshotNotFound(SnapshotError):
#     def __init__(self, module, test_name):
#         super(SnapshotNotFound, self).__init__(
#             "Snapshot '{snapshot_id!s}' not found in {snapshot_file!s}".format(
#                 snapshot_id=test_name, snapshot_file=module.filepath
#             )
#         )


import codecs
import errno
import os
import imp
import logging
from collections import defaultdict
from .snapshot import Snapshot
from .formatter import Formatter
from .error import SnapshotNotFound
        SnapshotTest._current_tester = None

    def visit(self):
        self.module.visit(self.test_name)

    def fail(self):
        self.module.mark_failed(self.test_name)

    def store(self, data):
        formatter = Formatter.get_formatter(data)
        data = formatter.store(self, data)
        self.module[self.test_name] = data

    def assert_value_matches_snapshot(self, test_value, snapshot_value):
        formatter = Formatter.get_formatter(test_value)
        formatter.assert_value_matches_snapshot(
            self, test_value, snapshot_value, Formatter()
        )

    def assert_equals(self, value, snapshot):
        assert value == snapshot

    def assert_match(self, value, name=""):
        self.curr_snapshot = name or self.snapshot_counter
        self.visit()
        if self.update:
            self.store(value)
        else:
            try:
                prev_snapshot = self.module[self.test_name]

# Path: snapshottest/snapshot.py
# class Snapshot(OrderedDict):
#     pass
# 
# Path: snapshottest/formatter.py
# class Formatter(object):
#     formatters = default_formatters()
# 
#     def __init__(self, imports=None):
#         self.htchar = " " * 4
#         self.lfchar = "\n"
#         self.indent = 0
#         self.imports = imports
# 
#     def __call__(self, value, **args):
#         return self.format(value, self.indent)
# 
#     def format(self, value, indent):
#         formatter = self.get_formatter(value)
#         for module, import_name in formatter.get_imports():
#             self.imports[module].add(import_name)
#         return formatter.format(value, indent, self)
# 
#     def normalize(self, value):
#         formatter = self.get_formatter(value)
#         return formatter.normalize(value, self)
# 
#     @staticmethod
#     def get_formatter(value):
#         for formatter in Formatter.formatters:
#             if formatter.can_format(value):
#                 return formatter
# 
#         # This should never happen as GenericFormatter is registered by default.
#         raise RuntimeError("No formatter found for value")
# 
#     @staticmethod
#     def register_formatter(formatter):
#         Formatter.formatters.insert(0, formatter)
# 
# Path: snapshottest/error.py
# class SnapshotNotFound(SnapshotError):
#     def __init__(self, module, test_name):
#         super(SnapshotNotFound, self).__init__(
#             "Snapshot '{snapshot_id!s}' not found in {snapshot_file!s}".format(
#                 snapshot_id=test_name, snapshot_file=module.filepath
#             )
#         )


# Path: snapshottest/module.py
import codecs
import errno
import os
import imp
import logging
from collections import defaultdict
from .snapshot import Snapshot
from .formatter import Formatter
from .error import SnapshotNotFound

        SnapshotTest._current_tester = None

    def visit(self):
        self.module.visit(self.test_name)

    def fail(self):
        self.module.mark_failed(self.test_name)

    def store(self, data):
        formatter = Formatter.get_formatter(data)
        data = formatter.store(self, data)
        self.module[self.test_name] = data

    def assert_value_matches_snapshot(self, test_value, snapshot_value):
        formatter = Formatter.get_formatter(test_value)
        formatter.assert_value_matches_snapshot(
            self, test_value, snapshot_value, Formatter()
        )

    def assert_equals(self, value, snapshot):
        assert value == snapshot

    def assert_match(self, value, name=""):
        self.curr_snapshot = name or self.snapshot_counter
        self.visit()
        if self.update:
            self.store(value)
        else:
            try:
                prev_snapshot = self.module[self.test_name]

            except SnapshotNotFound: