# Path: statik/errors.py
# class StatikErrorContext(object):
#     """Useful for representing context when exceptions are thrown (e.g. the name of
#     the current file being processed, line number, etc.)"""
#     
#     def __init__(self, filename=None, line_no=None):
#         self.filename = filename
#         self.line_no = line_no
# 
#     def render(self):
#         return ("in file \"%s\"%s" % (
#             self.filename,
#             (", line %d" % self.line_no) if self.line_no is not None else ""
#         )) if self.filename else None
#     
#     def update(self, filename=None, line_no=None):
#         self.filename = filename
#         self.line_no = line_no
#         
#         # line number is irrelevant now if no filename
#         if filename is None:
#             self.filename, self.line_no = None, None
#     
#     def clear(self):
#         self.filename, self.line_no = None, None


import unittest
from statik.errors import StatikErrorContext
# -*- coding: utf-8 -*-



class TestStatikErrorHandling(unittest.TestCase):

    def test_empty_error_context(self):
        context = StatikErrorContext()
        self.assertIsNone(context.render())

    def test_error_context_with_filename_only(self):
        context = StatikErrorContext(filename="somefilename.yml")
        self.assertEqual("in file \"somefilename.yml\"", context.render())

    def test_complete_error_context(self):

# Path: statik/errors.py
# class StatikErrorContext(object):
#     """Useful for representing context when exceptions are thrown (e.g. the name of
#     the current file being processed, line number, etc.)"""
#     
#     def __init__(self, filename=None, line_no=None):
#         self.filename = filename
#         self.line_no = line_no
# 
#     def render(self):
#         return ("in file \"%s\"%s" % (
#             self.filename,
#             (", line %d" % self.line_no) if self.line_no is not None else ""
#         )) if self.filename else None
#     
#     def update(self, filename=None, line_no=None):
#         self.filename = filename
#         self.line_no = line_no
#         
#         # line number is irrelevant now if no filename
#         if filename is None:
#             self.filename, self.line_no = None, None
#     
#     def clear(self):
#         self.filename, self.line_no = None, None


# Path: tests/modular/test_errors.py
import unittest
from statik.errors import StatikErrorContext

# -*- coding: utf-8 -*-



class TestStatikErrorHandling(unittest.TestCase):

    def test_empty_error_context(self):
        context = StatikErrorContext()
        self.assertIsNone(context.render())

    def test_error_context_with_filename_only(self):
        context = StatikErrorContext(filename="somefilename.yml")
        self.assertEqual("in file \"somefilename.yml\"", context.render())

    def test_complete_error_context(self):

        context = StatikErrorContext(filename="somefilename.yml", line_no=12)