Exemplo n.º 1
0
    def test_fill(self):
        s = screen.screen(10, 10)
        s.fill_region(10, 1, 1, 10, "X")
        s.fill_region(2, 2, 9, 9, "O")
        s.fill_region(8, 8, 3, 3, ":")
        s.fill_region(4, 7, 7, 4, "o")
        s.fill_region(6, 5, 5, 6, ".")
        assert str(s) == fill1_target

        s = screen.screen(11, 11)
        s.fill_region(1, 1, 11, 11, "X")
        s.fill_region(2, 2, 10, 10, "O")
        s.fill_region(9, 9, 3, 3, ":")
        s.fill_region(4, 8, 8, 4, "o")
        s.fill_region(7, 5, 5, 7, ".")
        s.fill_region(6, 6, 6, 6, "+")
        assert str(s) == fill2_target
Exemplo n.º 2
0
    def test_fill (self):
        s = screen.screen (10,10)
        s.fill_region (10,1,1,10,'X')
        s.fill_region (2,2,9,9,'O')
        s.fill_region (8,8,3,3,':')
        s.fill_region (4,7,7,4,'o')
        s.fill_region (6,5,5,6,'.')
        assert str(s) == fill1_target

        s = screen.screen (11,11)
        s.fill_region (1,1,11,11,'X')
        s.fill_region (2,2,10,10,'O')
        s.fill_region (9,9,3,3,':')
        s.fill_region (4,8,8,4,'o')
        s.fill_region (7,5,5,7,'.')
        s.fill_region (6,6,6,6,'+')
        assert str(s) == fill2_target
Exemplo n.º 3
0
    def test_fill(self):
        s = screen.screen(10, 10)
        s.fill_region(10, 1, 1, 10, "X")
        s.fill_region(2, 2, 9, 9, "O")
        s.fill_region(8, 8, 3, 3, ":")
        s.fill_region(4, 7, 7, 4, "o")
        s.fill_region(6, 5, 5, 6, ".")
        assert str(s) == fill1_target

        s = screen.screen(11, 11)
        s.fill_region(1, 1, 11, 11, "X")
        s.fill_region(2, 2, 10, 10, "O")
        s.fill_region(9, 9, 3, 3, ":")
        s.fill_region(4, 8, 8, 4, "o")
        s.fill_region(7, 5, 5, 7, ".")
        s.fill_region(6, 6, 6, 6, "+")
        assert str(s) == fill2_target
Exemplo n.º 4
0
 def make_screen_with_box_utf8(self, *args, **kwargs):
     '''Creates a screen containing a box drawn using double-line
     line drawing characters. The characters are fed in as
     UTF-8. '''
     s = screen.screen(2, 2, *args, **kwargs)
     s.put_abs(1, 1, b'\xe2\x95\x94')
     s.put_abs(1, 2, b'\xe2\x95\x97')
     s.put_abs(2, 1, b'\xe2\x95\x9a')
     s.put_abs(2, 2, b'\xe2\x95\x9d')
     return s
Exemplo n.º 5
0
 def make_screen_with_box_cp437(self, *args, **kwargs):
     '''Creates a screen containing a box drawn using double-line
     line drawing characters. The characters are fed in as
     CP437. '''
     s = screen.screen(2, 2, *args, **kwargs)
     s.put_abs(1, 1, b'\xc9')
     s.put_abs(1, 2, b'\xbb')
     s.put_abs(2, 1, b'\xc8')
     s.put_abs(2, 2, b'\xbc')
     return s
Exemplo n.º 6
0
 def make_screen_with_box_unicode(self, *args, **kwargs):
     '''Creates a screen containing a box drawn using double-line
     line drawing characters. The characters are fed in as
     unicode. '''
     s = screen.screen(2, 2, *args, **kwargs)
     s.put_abs(1, 1, u'\u2554')
     s.put_abs(1, 2, u'\u2557')
     s.put_abs(2, 1, u'\u255A')
     s.put_abs(2, 2, u'\u255D')
     return s
Exemplo n.º 7
0
 def make_screen_with_box_utf8(self, *args, **kwargs):
     """Creates a screen containing a box drawn using double-line
     line drawing characters. The characters are fed in as
     UTF-8. """
     s = screen.screen(2, 2, *args, **kwargs)
     s.put_abs(1, 1, b"\xe2\x95\x94")
     s.put_abs(1, 2, b"\xe2\x95\x97")
     s.put_abs(2, 1, b"\xe2\x95\x9a")
     s.put_abs(2, 2, b"\xe2\x95\x9d")
     return s
Exemplo n.º 8
0
 def make_screen_with_box_cp437(self, *args, **kwargs):
     """Creates a screen containing a box drawn using double-line
     line drawing characters. The characters are fed in as
     CP437. """
     s = screen.screen(2, 2, *args, **kwargs)
     s.put_abs(1, 1, b"\xc9")
     s.put_abs(1, 2, b"\xbb")
     s.put_abs(2, 1, b"\xc8")
     s.put_abs(2, 2, b"\xbc")
     return s
Exemplo n.º 9
0
 def make_screen_with_box_unicode(self, *args, **kwargs):
     """Creates a screen containing a box drawn using double-line
     line drawing characters. The characters are fed in as
     unicode. """
     s = screen.screen(2, 2, *args, **kwargs)
     s.put_abs(1, 1, u"\u2554")
     s.put_abs(1, 2, u"\u2557")
     s.put_abs(2, 1, u"\u255A")
     s.put_abs(2, 2, u"\u255D")
     return s
Exemplo n.º 10
0
 def make_screen_with_box_utf8(self, *args, **kwargs):
     """Creates a screen containing a box drawn using double-line
     line drawing characters. The characters are fed in as
     UTF-8. """
     s = screen.screen(2, 2, *args, **kwargs)
     s.put_abs(1, 1, b"\xe2\x95\x94")
     s.put_abs(1, 2, b"\xe2\x95\x97")
     s.put_abs(2, 1, b"\xe2\x95\x9a")
     s.put_abs(2, 2, b"\xe2\x95\x9d")
     return s
Exemplo n.º 11
0
 def make_screen_with_box_cp437(self, *args, **kwargs):
     """Creates a screen containing a box drawn using double-line
     line drawing characters. The characters are fed in as
     CP437. """
     s = screen.screen(2, 2, *args, **kwargs)
     s.put_abs(1, 1, b"\xc9")
     s.put_abs(1, 2, b"\xbb")
     s.put_abs(2, 1, b"\xc8")
     s.put_abs(2, 2, b"\xbc")
     return s
Exemplo n.º 12
0
 def make_screen_with_box_unicode(self, *args, **kwargs):
     """Creates a screen containing a box drawn using double-line
     line drawing characters. The characters are fed in as
     unicode. """
     s = screen.screen(2, 2, *args, **kwargs)
     s.put_abs(1, 1, u"\u2554")
     s.put_abs(1, 2, u"\u2557")
     s.put_abs(2, 1, u"\u255A")
     s.put_abs(2, 2, u"\u255D")
     return s
Exemplo n.º 13
0
    def test_no_bytes(self):
        s = screen.screen(2, 2, encoding=None)
        s.put_abs(1, 1, u'A')
        s.put_abs(2, 2, u'D')

        with self.assertRaises(TypeError):
            s.put_abs(1, 2, b'B')

        if PY3:
            assert str(s) == u'A \n D'
        else:
            assert unicode(s) == u'A \n D'
            # This will still work if it's limited to ascii
            assert str(s) == b'A \n D'
Exemplo n.º 14
0
    def test_no_bytes(self):
        s = screen.screen(2, 2, encoding=None)
        s.put_abs(1, 1, u"A")
        s.put_abs(2, 2, u"D")

        with self.assertRaises(TypeError):
            s.put_abs(1, 2, b"B")

        if PY3:
            assert str(s) == u"A \n D"
        else:
            assert unicode(s) == u"A \n D"
            # This will still work if it's limited to ascii
            assert str(s) == b"A \n D"
Exemplo n.º 15
0
    def test_no_bytes(self):
        s = screen.screen(2, 2, encoding=None)
        s.put_abs(1, 1, u"A")
        s.put_abs(2, 2, u"D")

        with self.assertRaises(TypeError):
            s.put_abs(1, 2, b"B")

        if PY3:
            assert str(s) == u"A \n D"
        else:
            assert unicode(s) == u"A \n D"
            # This will still work if it's limited to ascii
            assert str(s) == b"A \n D"
Exemplo n.º 16
0
 def make_screen_with_put (self):
     s = screen.screen(10,10)
     s.fill ('.')
     for r in range (1,s.rows + 1):
         if r % 2:
             s.put_abs (r, 1, str(r))
         else:
             s.put_abs (r, s.cols, str(r))
     for c in range (1,s.cols + 1):
         if c % 2:
             s.put_abs (1, c, str(c))
         else:
             s.put_abs (s.rows, c, str(c))
     s.put_abs(1,1, '\\')
     s.put_abs(1,s.cols, '/')
     s.put_abs(s.rows,1,'/')
     s.put_abs(s.rows, s.cols, '\\')
     s.put_abs(5,5,'\\')
     s.put_abs(5,6,'/')
     s.put_abs(6,5,'/')
     s.put_abs(6,6,'\\')
     return s