Exemplo n.º 1
0
    def test_set_text(self):
        c = Clipboard()
        text = "test"
        c.set_text(text)
        self.assertTrue(c.has_text())
        self.assertEqual(c.get_text(), text)
        self.assertEqual(c.text, text)

        # Setting the text to None clears the stored text.
        c.set_text(None)
        self.assertFalse(c.has_text())
        self.assertIs(c.get_text(), None)
Exemplo n.º 2
0
 def test_from_system_argument(self):
     # Test the optional from_system argument of Clipboard.__init__
     text = "something"
     Clipboard.set_system_text(text)
     c = Clipboard(from_system=True)
     self.assertEqual(c.text, text)
     self.assertTrue(c.has_text())
Exemplo n.º 3
0
 def test_set_text(self):
     c = Clipboard()
     text = "test"
     c.set_text(text)
     self.assertTrue(c.has_text())
     self.assertEqual(c.get_text(), text)
     self.assertEqual(c.text, text)
Exemplo n.º 4
0
    def test_has_text(self):
        # Test with an empty Clipboard instance.
        c = Clipboard()
        self.assertFalse(c.has_text())

        # Test with format_unicode only.
        c = Clipboard(contents={format_unicode: u"unicode text"})
        self.assertTrue(c.has_text())

        # Test with both text formats.
        c = Clipboard(contents={
            format_unicode: u"unicode text",
            format_text: b"text"
        })
        self.assertTrue(c.has_text())

        # Test with format_text only.
        c = Clipboard(contents={format_text: b"text"})
        self.assertTrue(c.has_text())
Exemplo n.º 5
0
    def test_has_text(self):
        # Test with an empty Clipboard instance.
        c = Clipboard()
        self.assertFalse(c.has_text())

        # Test with format_unicode only.
        c = Clipboard(contents={format_unicode: u"unicode text"})
        self.assertTrue(c.has_text())

        # Test with both text formats.
        c = Clipboard(contents={format_unicode: u"unicode text",
                                format_text: b"text"})
        self.assertTrue(c.has_text())

        # Test with format_text only.
        c = Clipboard(contents={format_text: b"text"})
        self.assertTrue(c.has_text())

        # Test with format_hdrop only.
        with NamedTemporaryFile() as f:
            c = Clipboard(contents={format_hdrop: f.name})
            self.assertFalse(c.has_text())
Exemplo n.º 6
0
    def test_empty(self):
        # A new clipboard has no content for the unicode format.
        c = Clipboard()

        # Neither does a new clipboard have text.
        self.assertFalse(c.has_text())