Skip to content

Commit d61db36

Browse files
author
Luiko Czub
committed
revert #34 changes for attachment unittests
commit a1da1a9 introduces a py2/py3 switch *binary_read_mode*, to avoid **TypeError: expected bytes-like object, not str** With enhancement #40, a generic source solution should be implemented. So the original test code is restored.
1 parent b5c4ebb commit d61db36

File tree

4 files changed

+17
-26
lines changed

4 files changed

+17
-26
lines changed

src/testlink/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
#
1818
# ------------------------------------------------------------------------
1919

20-
VERSION = '0.6.0-dev'
20+
VERSION = '0.6.0-dev40'
2121
TL_RELEASE = '1.9.12'
2222

test/utest-offline/testlinkapigeneric_offline_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,8 @@ def test__getAttachmentArgs_textfile(self):
677677
a_file=open(NEWATTACHMENT_PY)
678678
args = self.api._getAttachmentArgs(a_file)
679679
self.assertEqual('testlinkapigeneric_offline_test.py', args['filename'])
680-
self.assertEqual('text/plain', args['filetype'])
680+
# filetype is also os depended, either 'text/plain' or 'text/x-pyth0n'
681+
self.assertIn('text/', args['filetype'])
681682
self.assertIsNotNone(args['content'])
682683

683684

test/utest-online/testlinkapi_generic_online_test.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@
3131
import sys
3232
import os.path
3333

34-
if sys.version_info[0] == 3:
35-
BINARY_READ_MODE = 'rb'
36-
else:
37-
BINARY_READ_MODE = 'r'
38-
3934
if sys.version_info[0] == 2 and sys.version_info[1] == 6:
4035
# py26 needs backport unittest2
4136
import unittest2 as unittest
@@ -206,7 +201,7 @@ def test_reportTCResult_unknownID(self):
206201
buildname='build 4713', notes='note 4714' )
207202

208203
def test_uploadExecutionAttachment_unknownID(self):
209-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
204+
attachemantFile = open(os.path.realpath(__file__), 'r')
210205
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
211206
self.client.uploadExecutionAttachment(attachemantFile, 4712,
212207
title='title 4713', description='descr. 4714')
@@ -246,37 +241,37 @@ def test_deleteTestCaseSteps_unknownID(self):
246241
self.client.deleteTestCaseSteps('N-4711', steps, version=1)
247242

248243
def test_uploadRequirementSpecificationAttachment_unknownID(self):
249-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
244+
attachemantFile = open(os.path.realpath(__file__), 'r')
250245
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
251246
self.client.uploadRequirementSpecificationAttachment(attachemantFile, 4712,
252247
title='title 4713', description='descr. 4714')
253248

254249
def test_uploadRequirementAttachment_unknownID(self):
255-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
250+
attachemantFile = open(os.path.realpath(__file__), 'r')
256251
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
257252
self.client.uploadRequirementAttachment(attachemantFile, 4712,
258253
title='title 4713', description='descr. 4714')
259254

260255
def test_uploadTestProjectAttachment_unknownID(self):
261-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
256+
attachemantFile = open(os.path.realpath(__file__), 'r')
262257
with self.assertRaisesRegex(TLResponseError, '7000.*4712'):
263258
self.client.uploadTestProjectAttachment(attachemantFile, 4712,
264259
title='title 4713', description='descr. 4714')
265260

266261
def test_uploadTestSuiteAttachment_unknownID(self):
267-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
262+
attachemantFile = open(os.path.realpath(__file__), 'r')
268263
with self.assertRaisesRegex(TLResponseError, '8000.*4712'):
269264
self.client.uploadTestSuiteAttachment(attachemantFile, 4712,
270265
title='title 4713', description='descr. 4714')
271266

272267
def test_uploadTestCaseAttachment_unknownID(self):
273-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
268+
attachemantFile = open(os.path.realpath(__file__), 'r')
274269
with self.assertRaisesRegex(TLResponseError, '5000.*testcaseid'):
275270
self.client.uploadTestCaseAttachment(attachemantFile, 4712,
276271
title='title 4713', description='descr. 4714')
277272

278273
def test_uploadAttachment_unknownID(self):
279-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
274+
attachemantFile = open(os.path.realpath(__file__), 'r')
280275
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
281276
self.client.uploadAttachment(attachemantFile, 4712, 'nodes_hierarchy',
282277
title='title 4713', description='descr. 4714')

test/utest-online/testlinkapi_online_test.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
import sys
3131
import os.path
3232

33-
if sys.version_info[0] == 3:
34-
BINARY_READ_MODE = 'rb'
35-
else:
36-
BINARY_READ_MODE = 'r'
37-
3833
if sys.version_info[0] == 2 and sys.version_info[1] == 6:
3934
# py26 needs backport unittest2
4035
import unittest2 as unittest
@@ -200,7 +195,7 @@ def test_reportTCResult_unknownID(self):
200195
'note 4714')
201196

202197
def test_uploadExecutionAttachment_unknownID(self):
203-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
198+
attachemantFile = open(os.path.realpath(__file__), 'r')
204199
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
205200
self.client.uploadExecutionAttachment(attachemantFile, 4712,
206201
'title 4713', 'descr. 4714')
@@ -236,37 +231,37 @@ def test_deleteTestCaseSteps_unknownID(self):
236231
self.client.deleteTestCaseSteps('N-4711', steps, version=1)
237232

238233
def test_uploadRequirementSpecificationAttachment_unknownID(self):
239-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
234+
attachemantFile = open(os.path.realpath(__file__), 'r')
240235
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
241236
self.client.uploadRequirementSpecificationAttachment(attachemantFile, 4712,
242237
title='title 4713', description='descr. 4714')
243238

244239
def test_uploadRequirementAttachment_unknownID(self):
245-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
240+
attachemantFile = open(os.path.realpath(__file__), 'r')
246241
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
247242
self.client.uploadRequirementAttachment(attachemantFile, 4712,
248243
title='title 4713', description='descr. 4714')
249244

250245
def test_uploadTestProjectAttachment_unknownID(self):
251-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
246+
attachemantFile = open(os.path.realpath(__file__), 'r')
252247
with self.assertRaisesRegex(TLResponseError, '7000.*4712'):
253248
self.client.uploadTestProjectAttachment(attachemantFile, 4712,
254249
title='title 4713', description='descr. 4714')
255250

256251
def test_uploadTestSuiteAttachment_unknownID(self):
257-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
252+
attachemantFile = open(os.path.realpath(__file__), 'r')
258253
with self.assertRaisesRegex(TLResponseError, '8000.*4712'):
259254
self.client.uploadTestSuiteAttachment(attachemantFile, 4712,
260255
title='title 4713', description='descr. 4714')
261256

262257
def test_uploadTestCaseAttachment_unknownID(self):
263-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
258+
attachemantFile = open(os.path.realpath(__file__), 'r')
264259
with self.assertRaisesRegex(TLResponseError, '5000.*testcaseid'):
265260
self.client.uploadTestCaseAttachment(attachemantFile, 4712,
266261
title='title 4713', description='descr. 4714')
267262

268263
def test_uploadAttachment_unknownID(self):
269-
attachemantFile = open(os.path.realpath(__file__), BINARY_READ_MODE)
264+
attachemantFile = open(os.path.realpath(__file__), 'r')
270265
with self.assertRaisesRegex(TLResponseError, '6004.*4712'):
271266
self.client.uploadAttachment(attachemantFile, 4712, 'nodes_hierarchy',
272267
title='title 4713', description='descr. 4714')

0 commit comments

Comments
 (0)