text: # This file exists within 'easy-as-pypi-termio':
  #
  #   https://github.com/tallybark/easy-as-pypi-termio#🍉
  #
  # Copyright © 2018-2020 Landon Bouma. All rights reserved.
  #
  # Permission is hereby granted,  free of charge,  to any person obtaining a
  # copy of this software and associated documentation files (the "Software"),
  # to deal in the Software without restriction, including without limitation
  # the rights to use, copy, modify, merge,  publish,  distribute, sublicense,
  # and/or  sell copies  of the Software,  and to permit persons  to whom the
  # Software  is  furnished  to do so,  subject  to  the following conditions:
  #
  # The  above  copyright  notice  and  this  permission  notice  shall  be
  # included  in  all  copies  or  substantial  portions  of  the  Software.
  #
  # THE  SOFTWARE  IS  PROVIDED  "AS IS",  WITHOUT  WARRANTY  OF ANY KIND,
  # EXPRESS OR IMPLIED,  INCLUDING  BUT NOT LIMITED  TO THE WARRANTIES OF
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE  FOR ANY
  # CLAIM,  DAMAGES OR OTHER LIABILITY,  WHETHER IN AN ACTION OF CONTRACT,
  # TORT OR OTHERWISE,  ARISING FROM,  OUT OF  OR IN  CONNECTION WITH THE
  # SOFTWARE   OR   THE   USE   OR   OTHER   DEALINGS  IN   THE  SOFTWARE.
  
  import os  # noqa: F401
  import sys  # noqa: F401
  
  import pytest
  from unittest import mock
  
  try:
      import pyfiglet
  except ImportError:
      pyfiglet = None
  
  import click_hotoffthehamster as click
  
  from easy_as_pypi_termio.ascii_art import (
      append_figlet_text_maybe,
      fetch_asciis,
      infection_notice,
      lifeless,
      randomster,
      # ...
      curly_quote,
      curly_quotes,
  )
  
  
  if pyfiglet is not None:
  
      @mock.patch('pyfiglet.Figlet.getFonts', side_effect=Exception)
      def test_append_figlet_text_maybe_fail_if_pyfiglet_fails(figlet_mock):
          artwork = []
          with pytest.raises(Exception):
              append_figlet_text_maybe(artwork)
  
      @mock.patch.dict('sys.modules', {'pyfiglet': None})  # Raise ImportError.
      def test_append_figlet_text_maybe_noop_if_pyfiglet_missing():
          artwork = []
          append_figlet_text_maybe(artwork)
          assert not artwork
  
  
  def test_infection_notice():
      notice = infection_notice()
      assert notice
  
  
  def test_fetch_asciis():
      arts = fetch_asciis([0, 2])
      assert len(arts) == 2
  
  
  def test_fetch_asciis_index_error():
      arts = fetch_asciis([0, 2, 999])
      assert len(arts) == 1
  
  
  def test_randomster():
      art = randomster()
      assert art
  
  
  # (lb): Not sure why, but mock.patch does not work how I'd expect:
  #         @mock.patch('click.get_terminal_size', return_value=(0,))
  #       but a patch.object does.
  @mock.patch.object(click, 'get_terminal_size', return_value=(0,))
  def test_avail_width_none(get_terminal_size):
      art = randomster()
      assert art
  
  
  def test_lifeless():
      art = lifeless()
      assert art
  
  
  # ***
  
  # Somewhat misplaced functions...
  
  def test_curly_quote_okay():
      quoted = curly_quote('foo')
      assert quoted == '‘foo’'
  
  
  @mock.patch('os.name', new_callable=mock.PropertyMock(return_value='nt'))
  def test_curly_quote_fail(os_name):
      quoted = curly_quote('foo')
      assert quoted == "'foo'"
  
  
  def test_curly_quotes_okay():
      quoted = curly_quotes('foo')
      assert quoted == '“foo”'
  
  
  @mock.patch('os.name', new_callable=mock.PropertyMock(return_value='nt'))
  def test_curly_quotes_fail(os_name):
      quoted = curly_quotes('foo')
      assert quoted == '"foo"'
  
  