def test_mimedata_roundtrip(self):
        data_wrapper = DataWrapper()
        data_wrapper.set_mimedata('text/plain', b'hello world')
        result = data_wrapper.get_mimedata('text/plain')

        self.assertEqual(data_wrapper.mimetypes(), {'text/plain'})
        self.assertEqual(result, b'hello world')
Пример #2
0
    def test_add_data_length_2(self):
        exporter = ItemExporter(format=trivial_format)
        data_wrapper = DataWrapper()

        exporter.add_data(data_wrapper, self.model, [((), ()), ((0, ), (0, ))])

        self.assertFalse(data_wrapper.has_format(trivial_format))
Пример #3
0
    def test_add_data_fail(self):
        exporter = TrivialExporter(format=trivial_format)
        data_wrapper = DataWrapper()

        exporter.add_data(data_wrapper, self.model, [])

        self.assertFalse(data_wrapper.has_format(trivial_format))
Пример #4
0
    def test_add_data_(self):
        exporter = ItemExporter(format=trivial_format)
        data_wrapper = DataWrapper()

        exporter.add_data(data_wrapper, self.model, [((0, ), (0, ))])

        self.assertTrue(data_wrapper.has_format(trivial_format))
        self.assertEqual(data_wrapper.get_mimedata('null/null'), b'1')
    def test_set_format(self):
        data_wrapper = DataWrapper()
        format = text_format()

        data_wrapper.set_format(format, 'hëllø wørld')
        result = data_wrapper.get_mimedata('text/plain')

        self.assertEqual(data_wrapper.mimetypes(), {'text/plain'})
        self.assertEqual(result, 'hëllø wørld'.encode('utf-8'))
 def test_instantiate(self):
     data_wrapper = DataWrapper()
     self.assertEqual(data_wrapper.mimetypes(), set())