예제 #1
0
 def output_format(self, new_format=None):
     """Return our output format or set a new output format."""
     if new_format is not None:
         if not formats.is_format(new_format):
             raise TypeError('Argument %s is not a known format type',
                             new_format)
         self.out_format = new_format
     return self.out_format
예제 #2
0
    def test_is_format(self):
        self.assertTrue(formats.is_format(formats.Unknown))
        self.assertTrue(formats.is_format(formats.Bytes))
        self.assertTrue(formats.is_format(formats.JSON_Record))

        self.assertFalse(formats.is_format(formats.is_format))
        self.assertFalse(formats.is_format('a string'))
        self.assertFalse(formats.is_format(None))
        self.assertFalse(formats.is_format(self))