+
+
+ 0 |
+ |
+
+
+ 1 |
+ |
+
+
+ 2 |
+ |
+
+
+ """
+
+ list_of_dicts = [{'item1': 'value1'}, {'item2': 'value2'}, {'item3': 'value3'}]
+ self.assertEqual(
+ format_html(format_value(list_of_dicts)),
+ format_html(expected_dict_format)
+ )
+
+ def test_format_value_simple_string(self):
+ """
+ Tests format_value with a simple string
+ """
+ simple_string = 'this is an example of a string'
+ self.assertEqual(format_value(simple_string), simple_string)
+
+ def test_format_value_string_hyperlink(self):
+ """
+ Tests format_value with a url
+ """
+ url = 'http://www.example.com'
+ self.assertEqual(format_value(url), 'http://www.example.com')
+
+ def test_format_value_string_email(self):
+ """
+ Tests format_value with an email address
+ """
+ email = 'something@somewhere.com'
+ self.assertEqual(format_value(email), 'something@somewhere.com')
+
+ def test_format_value_string_newlines(self):
+ """
+ Tests format_value with a string with newline characters
+ :return:
+ """
+ text = 'Dear user, \n this is a message \n from,\nsomeone'
+ self.assertEqual(format_value(text), 'Dear user, \n this is a message \n from,\nsomeone
')
+
+ def test_format_value_object(self):
+ """
+ Tests that format_value with a object returns the object's __str__ method
+ """
+ obj = object()
+ self.assertEqual(format_value(obj), obj.__str__())
+
+ def test_add_nested_class(self):
+ """
+ Tests that add_nested_class returns the proper class
+ """
+ positive_cases = [
+ [['item']],
+ [{'item1': 'value1'}],
+ {'item1': 'value1'}
+ ]
+
+ negative_cases = [
+ ['list'],
+ '',
+ None,
+ True,
+ False
+ ]
+
+ for case in positive_cases:
+ self.assertEqual(add_nested_class(case), 'class=nested')
+
+ for case in negative_cases:
+ self.assertEqual(add_nested_class(case), '')
+
class Issue1386Tests(TestCase):
"""