new_contents: # vim: set et ts=4 sw=4 fdm=marker
  """
  MIT License
  
  Copyright (c) 2016 Jesse Hogan
  
  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.
  """
  from tester import *
  
  class test_entities(tester):
      def it_instantiates(self):
  
          # Plain ol' instantiate
          try:
              es = entities()
          except:
              self.assertFail('Failed instantiating entities')
  
          # Instantiate with an array of entities
          e1, e2 = entity(), entity()
  
          es = entities([e1, e2])
  
          self.assertIs(e1, es[0])
          self.assertIs(e2, es[1])
  
      def it_clears(self):
          """ Test to ensure the clear() method removes entities. """
          es = entities([entity(), entity()])
          es.clear()
          self.assertTrue(es.isempty)
          
      def it_calls(self):
          """ Test that the indexer (__call__()) returns the the correct entity
          or None if the index is invalid. """
          e1, e2 = entity(), entity()
  
          es = entities([e1, e2])
  
          self.assertIs(e1, es(0))
          self.assertIs(e2, es(1))
  
          try:
              e = es(2)
          except:
              self.assertFail('__call__ should return None if index is invalid.')
  
          self.assertNone(es(2))
  
      def it_iterates(self):
          """ Ensure the iterator (__iter__()) works. """
          e1, e2 = entity(), entity()
  
          es = entities([e1, e2])
  
          for i, e in enumerate(es):
              if i == 0:
                  self.assertIs(e1, e)
              elif i == 1:
                  self.assertIs(e2, e)
              else:
                  self.assertFail('We should have only interated twice.')
  
      def it_gets_random(self):
          """ Ensure es.getrandom() eventually returns a random entity. """
          e1, e2 = entity(), entity()
          es = entities([e1, e2])
  
          got1 = got2 = False
          for _ in range(100):
              e = es.getrandom()
              if e is e1:
                  got1 = True
              elif e is e2:
                  got2 = True
  
              if got1 and got2:
                  break
  
          if not (got1 and got2):
              self.assertFail('Failed getting random entities')
  
  print(testers())
  
  
  
  
subject: Add test.py