def test_can_contain_dict(self): x = 'hello' y = 'world' self.assertEqual(compact(x, y, {'z': 'foo'}), { 'x': 'hello', 'y': 'world', 'z': 'foo' })
def test_compact_returns_dict_of_local_variable(self): x = 'hello' self.assertEqual(compact(x), {'x': 'hello'})
def test_works_with_classes(self): request = Request(None) self.assertIn('request', compact(request))
def test_compact_throws_exceptions(self): r = Request(None) request = r with self.assertRaises(AmbiguousError): compact(request)
def test_exception_on_too_many(self): x = 'hello' y = 'world' with self.assertRaises(ValueError): compact(x, y, 'z')
def test_works_with_several_variables(self): x = 'hello' y = 'world' self.assertEqual(compact(x, y), {'x': 'hello', 'y': 'world'})