bpo-1102: View.Fetch() now returns None when it's exhausted (GH-4459) · python/cpython@bdb8315 (original) (raw)

1

1

`""" Test suite for the code in msilib """

`

2

2

`import unittest

`

3

``

`-

from test.support import import_module

`

``

3

`+

from test.support import TESTFN, import_module, unlink

`

4

4

`msilib = import_module('msilib')

`

``

5

`+

import msilib.schema

`

``

6

+

``

7

+

``

8

`+

def init_database():

`

``

9

`+

path = TESTFN + '.msi'

`

``

10

`+

db = msilib.init_database(

`

``

11

`+

path,

`

``

12

`+

msilib.schema,

`

``

13

`+

'Python Tests',

`

``

14

`+

'product_code',

`

``

15

`+

'1.0',

`

``

16

`+

'PSF',

`

``

17

`+

)

`

``

18

`+

return db, path

`

``

19

+

``

20

+

``

21

`+

class MsiDatabaseTestCase(unittest.TestCase):

`

``

22

+

``

23

`+

def test_view_fetch_returns_none(self):

`

``

24

`+

db, db_path = init_database()

`

``

25

`+

properties = []

`

``

26

`+

view = db.OpenView('SELECT Property, Value FROM Property')

`

``

27

`+

view.Execute(None)

`

``

28

`+

while True:

`

``

29

`+

record = view.Fetch()

`

``

30

`+

if record is None:

`

``

31

`+

break

`

``

32

`+

properties.append(record.GetString(1))

`

``

33

`+

view.Close()

`

``

34

`+

db.Close()

`

``

35

`+

self.assertEqual(

`

``

36

`+

properties,

`

``

37

`+

[

`

``

38

`+

'ProductName', 'ProductCode', 'ProductVersion',

`

``

39

`+

'Manufacturer', 'ProductLanguage',

`

``

40

`+

]

`

``

41

`+

)

`

``

42

`+

self.addCleanup(unlink, db_path)

`

``

43

+

5

44

``

6

45

`class Test_make_id(unittest.TestCase):

`

7

46

`#http://msdn.microsoft.com/en-us/library/aa369212(v=vs.85).aspx

`