|
28 | 28 | # ok to check every implemented server call one time but not
|
29 | 29 | # to cover all possible responses or argument combinations
|
30 | 30 |
|
| 31 | +import sys |
31 | 32 | import unittest, os.path
|
32 | 33 | from testlink import TestlinkAPIGeneric, TestLinkHelper
|
33 | 34 | from testlink.testlinkerrors import TLResponseError
|
34 | 35 |
|
35 |
| -import sys |
| 36 | +binary_read_mode = 'rb' |
36 | 37 | if sys.version_info[0] < 3:
|
| 38 | + binary_read_mode = 'r' |
| 39 | + if sys.version_info[1] < 7: |
| 40 | + import unittest2 as unittest |
37 | 41 | unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
|
38 | 42 |
|
39 | 43 |
|
40 |
| - |
41 | 44 | class TestLinkAPIOnlineTestCase(unittest.TestCase):
|
42 | 45 | """ TestCases for TestlinkAPIClient - interacts with a TestLink Server.
|
43 | 46 | works with the example project NEW_PROJECT_API (see TestLinkExample.py)
|
@@ -191,7 +194,7 @@ def test_reportTCResult_unknownID(self):
|
191 | 194 | buildname='build 4713', notes='note 4714' )
|
192 | 195 |
|
193 | 196 | def test_uploadExecutionAttachment_unknownID(self):
|
194 |
| - attachemantFile = open(os.path.realpath(__file__), 'r') |
| 197 | + attachemantFile = open(os.path.realpath(__file__), binary_read_mode) |
195 | 198 | with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
|
196 | 199 | self.client.uploadExecutionAttachment(attachemantFile, 4712,
|
197 | 200 | title='title 4713', description='descr. 4714')
|
@@ -231,45 +234,45 @@ def test_deleteTestCaseSteps_unknownID(self):
|
231 | 234 | self.client.deleteTestCaseSteps('N-4711', steps, version=1)
|
232 | 235 |
|
233 | 236 | def test_uploadRequirementSpecificationAttachment_unknownID(self):
|
234 |
| - attachemantFile = open(os.path.realpath(__file__), 'r') |
| 237 | + attachemantFile = open(os.path.realpath(__file__), binary_read_mode) |
235 | 238 | with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
|
236 | 239 | self.client.uploadRequirementSpecificationAttachment(attachemantFile, 4712,
|
237 | 240 | title='title 4713', description='descr. 4714')
|
238 | 241 |
|
239 | 242 | def test_uploadRequirementAttachment_unknownID(self):
|
240 |
| - attachemantFile = open(os.path.realpath(__file__), 'r') |
| 243 | + attachemantFile = open(os.path.realpath(__file__), binary_read_mode) |
241 | 244 | with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
|
242 | 245 | self.client.uploadRequirementAttachment(attachemantFile, 4712,
|
243 | 246 | title='title 4713', description='descr. 4714')
|
244 | 247 |
|
245 | 248 | def test_uploadTestProjectAttachment_unknownID(self):
|
246 |
| - attachemantFile = open(os.path.realpath(__file__), 'r') |
| 249 | + attachemantFile = open(os.path.realpath(__file__), binary_read_mode) |
247 | 250 | with self.assertRaisesRegex(TLResponseError, '7000.*4712'):
|
248 | 251 | self.client.uploadTestProjectAttachment(attachemantFile, 4712,
|
249 | 252 | title='title 4713', description='descr. 4714')
|
250 | 253 |
|
251 | 254 | def test_uploadTestSuiteAttachment_unknownID(self):
|
252 |
| - attachemantFile = open(os.path.realpath(__file__), 'r') |
| 255 | + attachemantFile = open(os.path.realpath(__file__), binary_read_mode) |
253 | 256 | with self.assertRaisesRegex(TLResponseError, '8000.*4712'):
|
254 | 257 | self.client.uploadTestSuiteAttachment(attachemantFile, 4712,
|
255 | 258 | title='title 4713', description='descr. 4714')
|
256 | 259 |
|
257 | 260 | def test_uploadTestCaseAttachment_unknownID(self):
|
258 |
| - attachemantFile = open(os.path.realpath(__file__), 'r') |
| 261 | + attachemantFile = open(os.path.realpath(__file__), binary_read_mode) |
259 | 262 | with self.assertRaisesRegex(TLResponseError, '5000.*testcaseid'):
|
260 | 263 | self.client.uploadTestCaseAttachment(attachemantFile, 4712,
|
261 | 264 | title='title 4713', description='descr. 4714')
|
262 | 265 |
|
263 | 266 | def test_uploadAttachment_unknownID(self):
|
264 |
| - attachemantFile = open(os.path.realpath(__file__), 'r') |
| 267 | + attachemantFile = open(os.path.realpath(__file__), binary_read_mode) |
265 | 268 | with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
|
266 | 269 | self.client.uploadAttachment(attachemantFile, 4712, 'nodes_hierarchy',
|
267 | 270 | title='title 4713', description='descr. 4714')
|
268 |
| - |
| 271 | + |
269 | 272 | def test_checkDevKey_unknownKey(self):
|
270 | 273 | with self.assertRaisesRegex(TLResponseError, '2000.*invalid'):
|
271 | 274 | self.client.checkDevKey(devKey='unknownKey')
|
272 |
| - |
| 275 | + |
273 | 276 | def test_testLinkVersion(self):
|
274 | 277 | response = self.client.testLinkVersion()
|
275 | 278 | self.assertRegex(response, '\d*\.\d*\.\d*')
|
|
0 commit comments