~ubuntu-branches/ubuntu/natty/pyside/natty

« back to all changes in this revision

Viewing changes to tests/QtCore/qresource_test.py

  • Committer: Bazaar Package Importer
  • Author(s): Didier Raboud
  • Date: 2011-02-18 18:01:00 UTC
  • mfrom: (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110218180100-y8aqmcdbcbd6gpeh
Tags: upstream-1.0.0~rc1
ImportĀ upstreamĀ versionĀ 1.0.0~rc1

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
import unittest
6
6
import os
 
7
from helper import adjust_filename
7
8
from PySide.QtCore import QFile, QIODevice
8
9
import resources_mc
9
10
 
10
11
class ResourcesUsage(unittest.TestCase):
11
12
    '''Test case for resources usage'''
12
13
 
13
 
    def setUp(self):
14
 
        f = open(os.path.join(os.path.dirname(__file__), 'quoteEnUS.txt'))
15
 
        self.text = f.read()
16
 
        f.close()
17
 
 
18
 
    def tearDown(self):
19
 
        self.text = None
20
 
 
21
14
    def testPhrase(self):
22
15
        #Test loading of quote.txt resource
 
16
        f = open(adjust_filename('quoteEnUS.txt', __file__), "r")
 
17
        orig = f.read()
 
18
        f.close()
 
19
 
23
20
        f = QFile(':/quote.txt')
24
21
        f.open(QIODevice.ReadOnly|QIODevice.Text)
25
 
        content = f.readAll()
26
 
        f.close()
27
 
        self.assertEqual(self.text, content)
 
22
        copy = f.readAll()
 
23
        f.close()
 
24
        self.assertEqual(orig, copy)
 
25
 
 
26
    def testImage(self):
 
27
        #Test loading of sample.png resource
 
28
        f = open(adjust_filename('sample.png', __file__), "rb")
 
29
        orig = f.read()
 
30
        f.close()
 
31
 
 
32
        f = QFile(':/sample.png')
 
33
        f.open(QIODevice.ReadOnly)
 
34
        copy = f.readAll()
 
35
        f.close()
 
36
        self.assertEqual(len(orig), len(copy))
 
37
        self.assertEqual(orig, copy)
 
38
 
28
39
 
29
40
if __name__ == '__main__':
30
41
    unittest.main()