当前位置: 首页>>代码示例>>Python>>正文


Python Picture.addMessage方法代码示例

本文整理汇总了Python中Picture.addMessage方法的典型用法代码示例。如果您正苦于以下问题:Python Picture.addMessage方法的具体用法?Python Picture.addMessage怎么用?Python Picture.addMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Picture的用法示例。


在下文中一共展示了Picture.addMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Test_Picture

# 需要导入模块: import Picture [as 别名]
# 或者: from Picture import addMessage [as 别名]
class Test_Picture(unittest.TestCase):

    # def setUp(self):
        # No code needed here
        # Would run at the start of every individual test

    #
    # Timmy: I think these null tests are worthless since the book
    #        doesn't ever use a null picture, it always uses
    #        makePicture(filename)

    #   def testPictureNull1(self):
    #       '''Test Picture() constructor [1] - filename'''
    #       self.pict = Picture()
    #       self.assertEqual('%s'%self.pict.getFileName(), 'None', 'Filename %s != None' % self.pict.getFileName())

    #   def testPictureNull2(self):
    #       '''Test Picture() constructor [2] - extension'''
    #       self.pict = Picture()
    #       self.assertEqual('%s'%self.pict.getExtension(), 'None',  'File extension %s != None' % self.pict.getExtension())

    #   def testPictureNull3(self):
    #       '''Test Picture() constructor [3] - title'''
    #       self.pict = Picture()
    #       self.assertEqual('%s'%self.pict.getTitle(), 'None', 'Title %s != None' % self.pict.getTitle())

    #   def testPictureNull4(self):
    #       '''Test Picture() constructor [4] - width'''
    #       self.pict = Picture()
    #       self.assertEqual(self.pict.getWidth(), 0, 'Width %s != 0' % self.pict.getWidth())
    #       self.assertNotEqual(self.pict.getWidth(), 1, 'Width is 1?')

    #   def testPictureNull5(self):
    #       '''Test Picture() constructor [5] - height'''
    #       self.pict = Picture()
    #       self.assertEqual(self.pict.getHeight(), 0, 'Height %s != 0' % self.pict.getHeight())

    #   def testPictureNull6(self):
    #       '''Test Picture() constructor [6] - toString'''
    #       self.pict = Picture()
    #       self.assertEqual(self.pict.toString(), 'Picture, filename null height 0 width 0',
    #                   'toString %s != Picture, filename null height 0 width 0' % self.pict.toString())

    #   def testPictureNull(self):
    #       '''Test Picture() constructor [all]'''
    #       self.pict = Picture()
    # NOTE: Must do a null check here by sending null to '%s' so it prints as 'None' and does not
    # end up throwing a null pointer exception
    #       self.assertEqual('%s'%self.pict.getFileName(), 'None', 'Filename %s != None' % self.pict.getFileName())
    #       self.assertEqual('%s'%self.pict.getExtension(), 'None',  'File extension %s != None' % self.pict.getExtension())
    #       self.assertEqual('%s'%self.pict.getTitle(), 'None', 'Title %s != None' % self.pict.getTitle())
    #       self.assertEqual(self.pict.getWidth(), 0, 'Width %s != 0' % self.pict.getWidth())
    #       self.assertEqual(self.pict.getHeight(), 0, 'Height %s != 0' % self.pict.getHeight())
    #       self.assertNotEqual(self.pict.getWidth(), 1, 'Width is 1?')
    #       self.assertEqual(self.pict.toString(), 'Picture, filename None height 0 width 0',
    #                   'toString %s != Picture, filename None height 0 width 0' % self.pict.toString())

    def testPictureWdtHgt(self):
        '''Test Picture(width, height) constructor'''
        self.pict = Picture(500, 500)
        # NOTE: Must do a null check here by sending null to '%s' so it prints as 'None' and does not
        #    end up throwing a null pointer exception
#       self.assertEqual('%s'%self.pict.getFileName(), 'None', 'Filename %s != None' % self.pict.getFileName())
#       self.assertEqual(self.pict.getExtension(), 'jpg', 'File extension %s != jpg' % self.pict.getExtension())
#       self.assertEqual(self.pict.getTitle(), 'New Picture', 'Title %s != New Picture' % self.pict.getTitle())
        self.assertEqual(
            media.getWidth(self.pict), 500, 'Width %s != 500' % self.pict.getWidth())
        self.assertEqual(
            media.getHeight(self.pict), 500, 'Height %s != 500' % self.pict.getHeight())
#       self.assertNotEqual(self.pict.getWidth(), 499, 'Width is 499?')
#       self.assertEqual(self.pict.toString(), 'Picture, filename null height 500 width 500',
#                   'toString %s != Picture, filename null height 500 width 500' % self.pict.toString())

    def testTitleP(self):
        '''Test picture - changing title from Picture()'''
        self.pict = Picture()
        self.assertEqual(
            '%s' % self.pict.getTitle(), 'None', 'Title %s != None' % self.pict.getTitle())
        self.pict.setTitle("Blank object")
        self.assertNotEqual(
            '%s' % self.pict.getTitle(), 'None', 'Title did not change')
        self.assertEqual(self.pict.getTitle(), 'Blank object',
                         'Title %s != Blank object' % self.pict.getTitle())

    def testTitlePII(self):
        '''Test picture - changing title from Picture(int,int)'''
        self.pict = Picture(20, 20)
        self.assertEqual(
            '%s' % self.pict.getTitle(), 'None', 'Title %s != None' % self.pict.getTitle())
        self.pict.setTitle("Blank object")
        self.assertNotEqual(
            '%s' % self.pict.getTitle(), 'None', 'Title did not change')
        self.assertEqual(self.pict.getTitle(), 'Blank object',
                         'Title %s != Blank object' % self.pict.getTitle())

    def testAddMessage(self):
        '''Test Picture.addMessage'''
        self.pict = Picture(150, 50)
        self.pict.addMessage("This is a test", 25, 25)
        self.pict.addText(media.red, 10, 10, "test")
#.........这里部分代码省略.........
开发者ID:HenryStevens,项目名称:jes,代码行数:103,代码来源:Test_Picture_NEW.py


注:本文中的Picture.addMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。