def testEnvironment_set_params(self): # Make instant with params and args. env = Environment(params=['KEY_1', 'KEY_2'], args=['VAL_1', 'VAL_2']) # `find` method must return self and we can get values for keys. self.assertEqual(env.find('KEY_1')['KEY_1'], 'VAL_1') self.assertEqual(env.find('KEY_2')['KEY_2'], 'VAL_2')
def testEnvironment_extend(self): env = Environment() # A environment that have itself as an outer environment. extended_env = env.extend() # An outer environment must be itself. self.assertTrue(extended_env.outer is env)
def testEnvironment_find_value(self): env = Environment() # Add key-value pair for testing `find` method. env['KEY'] = 'VAL' # `find` method must return self and we can get value for key. self.assertEqual(env.find('KEY')['KEY'], 'VAL')
def testEnvironment_find(self): env = Environment() # Add key-value pair for testing `find` method. env['KEY'] = 'VAL' # `find` method must return self. self.assertEqual(env.find('KEY'), env)
def testEnvironment_find_outer_value(self): # Set outer environment. outer = Environment() env = Environment(outer=outer) # Add key-value pari to outer environment. env.outer['OUTER_KEY'] = 'OUTER_VAL' # `find` method must retrun outer environment and we can get outer value for outer key. self.assertEqual(env.find('OUTER_KEY')['OUTER_KEY'], 'OUTER_VAL')
def testEnvironment_find_outer(self): # Set outer environment. outer = Environment() env = Environment(outer=outer) # Add key-value pari to outer environment. env.outer['OUTER_KEY'] = ['OUTER_VAL'] # `find` method must retrun outer environment. self.assertEqual(env.find('OUTER_KEY'), outer)
def testEnvironment_find_raise_exception(self): env = Environment() # Raise exception if key-value pair does not exist. self.assertRaises(LookupError, env.find, 'KEY')
def testEnvironment(self): env = Environment() # Check instance. self.assertIsInstance(env, Environment)