Use o3tl::convert in Math
[LibreOffice.git] / pyuno / qa / pytests / testcollections_misc.py
blob1dba098eeccd69465bae1aacba477614e35daf9a
1 #!/usr/bin/env python
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 import unittest
11 import uno
13 from testcollections_base import CollectionsTestBase
14 from com.sun.star.beans import PropertyValue
17 # Miscellaneous tests of the behaviour of UNO objects using the new-style
18 # collection accessors
20 class TestMisc(CollectionsTestBase):
22 # Tests syntax:
23 # for val in obj: ... # Implicit iterator
24 # For:
25 # Invalid type
26 def test_misc_IterateInvalidType(self):
27 # Given
28 doc = self.createBlankTextDocument()
30 # When / Then
31 with self.assertRaises(TypeError):
32 for val in doc.UIConfigurationManager:
33 pass
35 doc.close(True)
37 # Tests syntax:
38 # if val in itr: ... # Test value presence
39 # For:
40 # Invalid type
41 def test_misc_InInvalidType(self):
42 # Given
43 doc = self.createBlankTextDocument()
45 # When / Then
46 with self.assertRaises(TypeError):
47 foo = "bar" in doc.UIConfigurationManager
49 doc.close(True)
51 # Tests syntax:
52 # num = len(obj) # Number of elements
53 # For:
54 # Invalid type
55 def test_misc_LenInvalidType(self):
56 # Given
57 doc = self.createBlankTextDocument()
59 # When / Then
60 with self.assertRaises(TypeError):
61 len(doc.UIConfigurationManager)
63 doc.close(True)
65 # Tests syntax:
66 # val = obj[0] # Access by index
67 # For:
68 # Invalid type
69 def test_misc_SubscriptInvalidType(self):
70 # Given
71 doc = self.createBlankTextDocument()
73 # When / Then
74 with self.assertRaises(TypeError):
75 doc.UIConfigurationManager[0]
77 doc.close(True)
80 if __name__ == '__main__':
81 unittest.main()
83 # vim:set shiftwidth=4 softtabstop=4 expandtab: