# Path: htmlgen/image.py
# class Image(VoidElement):
#     """An HTML image (<img>) element.
# 
#     Images must have an alternate text description that describes the
#     contents of the image, if the image can not be displayed. In some
#     cases the alternate text can be empty. For example, if the image just
#     displays a company logo next to the company's name or if the image just
#     adds an icon next to a textual description of an action.
# 
#     Example:
# 
#         >>> image = Image("whiteboard.jpg",
#         ...               "A whiteboard filled with mathematical formulas.")
#         >>> image.title = "Whiteboards are a useful tool"
#     """
# 
#     def __init__(self, url, alternate_text=""):
#         super().__init__("img")
#         self.url = url
#         self.alternate_text = alternate_text
# 
#     url = html_attribute("src")
#     alternate_text = html_attribute("alt")
#     title = html_attribute("title")
# 
# Path: test_htmlgen/util.py
# def parse_short_tag(string):
#     matches = _short_tag_re.match(string)
#     assert matches is not None
#     tag = Tag(matches.group(1))
#     attribute_string = matches.group(2)
#     for match in _attribute_re.findall(attribute_string):
#         tag.add_attribute(*match)
#     return tag


from unittest import TestCase
from asserts import assert_equal
from htmlgen import Image
from test_htmlgen.util import parse_short_tag





class ImageTest(TestCase):
    def test_attributes(self):
        image = Image("my-image.png", "Alternate text")
        assert_equal("my-image.png", image.url)
        assert_equal("Alternate text", image.alternate_text)

    def test_attributes_default_alt(self):
        image = Image("my-image.png")
        assert_equal("", image.alternate_text)

    def test_with_alt(self):
        image = Image("my-image.png", "Alternate text")
        tag = parse_short_tag(str(image))
        assert_equal("img", tag.name)
        assert_equal("my-image.png", image.get_attribute("src"))
        assert_equal("Alternate text", image.get_attribute("alt"))

    def test_without_alt(self):
        image = Image("my-image.png")

# Path: htmlgen/image.py
# class Image(VoidElement):
#     """An HTML image (<img>) element.
# 
#     Images must have an alternate text description that describes the
#     contents of the image, if the image can not be displayed. In some
#     cases the alternate text can be empty. For example, if the image just
#     displays a company logo next to the company's name or if the image just
#     adds an icon next to a textual description of an action.
# 
#     Example:
# 
#         >>> image = Image("whiteboard.jpg",
#         ...               "A whiteboard filled with mathematical formulas.")
#         >>> image.title = "Whiteboards are a useful tool"
#     """
# 
#     def __init__(self, url, alternate_text=""):
#         super().__init__("img")
#         self.url = url
#         self.alternate_text = alternate_text
# 
#     url = html_attribute("src")
#     alternate_text = html_attribute("alt")
#     title = html_attribute("title")
# 
# Path: test_htmlgen/util.py
# def parse_short_tag(string):
#     matches = _short_tag_re.match(string)
#     assert matches is not None
#     tag = Tag(matches.group(1))
#     attribute_string = matches.group(2)
#     for match in _attribute_re.findall(attribute_string):
#         tag.add_attribute(*match)
#     return tag


# Path: test_htmlgen/image.py
from unittest import TestCase
from asserts import assert_equal
from htmlgen import Image
from test_htmlgen.util import parse_short_tag






class ImageTest(TestCase):
    def test_attributes(self):
        image = Image("my-image.png", "Alternate text")
        assert_equal("my-image.png", image.url)
        assert_equal("Alternate text", image.alternate_text)

    def test_attributes_default_alt(self):
        image = Image("my-image.png")
        assert_equal("", image.alternate_text)

    def test_with_alt(self):
        image = Image("my-image.png", "Alternate text")
        tag = parse_short_tag(str(image))
        assert_equal("img", tag.name)
        assert_equal("my-image.png", image.get_attribute("src"))
        assert_equal("Alternate text", image.get_attribute("alt"))

    def test_without_alt(self):
        image = Image("my-image.png")

        tag = parse_short_tag(str(image))