コード例 #1
0
 def test_formatting_none(self):
     """Run None through formatters."""
     self.assertEqual("", StringFormatter().format(None))
     self.assertEqual("",
                      JoinFormatter(',', DisallowFormatter()).format(None))
     self.assertEqual("", StrftimeFormatter("%m/%02d/%Y").format(None))
     self.assertEqual([],
                      MultiFieldDescend(['a'],
                                        NoopFormatter()).format(None))
     self.assertEqual(
         '',
         SingleFieldDescend(None, NoopFormatter()).format(None))
コード例 #2
0
 def test_single_field_descend_non_dict(self):
     """Test that we can handle non-dicts."""
     formatter = SingleFieldDescend('name', StringFormatter())
     self.assertEqual('1', formatter.format(1))
コード例 #3
0
 def test_single_field_descend_missing_key(self):
     """Test that we can descend a dict when the key is missing."""
     formatter = SingleFieldDescend('name', NoopFormatter())
     self.assertEqual(None, formatter.format({'b': 'c'}))
コード例 #4
0
 def test_single_field_descend(self):
     """Test that we can descend a single field in a dict."""
     formatter = SingleFieldDescend('name', NoopFormatter())
     self.assertEqual("aa", formatter.format({'name': 'aa', 'b': 'c'}))
コード例 #5
0
 def test_single_field_descend_non_dict(self):
     """Test that we can handle non-dicts."""
     formatter = SingleFieldDescend('name', StringFormatter())
     self.assertEqual('1', formatter.format(1))
コード例 #6
0
 def test_single_field_descend_missing_key(self):
     """Test that we can descend a dict when the key is missing."""
     formatter = SingleFieldDescend('name', NoopFormatter())
     self.assertEqual(None, formatter.format({'b': 'c'}))
コード例 #7
0
 def test_single_field_descend(self):
     """Test that we can descend a single field in a dict."""
     formatter = SingleFieldDescend('name', NoopFormatter())
     self.assertEqual("aa", formatter.format({'name': 'aa', 'b': 'c'}))