20
20
# this test works WITHOUT an online TestLink Server
21
21
# no calls are send to a TestLink Server
22
22
23
- import sys
23
+ import sys , os . path
24
24
25
25
if sys .version_info [0 ] == 2 and sys .version_info [1 ] == 6 :
26
26
# py26 needs backport unittest2
@@ -665,8 +665,24 @@ def test_whatArgs_getLastExecutionResult(self):
665
665
argsDescription = self .api .whatArgs ('getLastExecutionResult' )
666
666
self .assertIn ('options=<options>' , argsDescription )
667
667
self .assertIn ('getBugs' , argsDescription )
668
+
669
+ def test__getAttachmentArgs_textfile (self ):
670
+ "py3 issue #39 TypeError: expected bytes-like object, not str"
671
+ NEWATTACHMENT_PY = os .path .realpath (__file__ )
672
+ # under py2, on windows text files should be open with 'r' mode and
673
+ # binary files with 'rb'
674
+ # see http://docs.python.org/2/tutorial/inputoutput.html#reading-and-writing-files
675
+ # under py3, text files open with 'r' on windows makes problem
676
+ # see https://github.com/lczub/TestLink-API-Python-client/issues/39
677
+ a_file = open (NEWATTACHMENT_PY )
678
+ args = self .api ._getAttachmentArgs (a_file )
679
+ self .assertEqual ('testlinkapigeneric_offline_test.py' , args ['filename' ])
680
+ self .assertEqual ('text/plain' , args ['filetype' ])
681
+ self .assertIsNotNone (args ['content' ])
682
+
683
+
668
684
669
-
685
+
670
686
if __name__ == "__main__" :
671
687
#import sys;sys.argv = ['', 'Test.testName']
672
688
unittest .main ()
0 commit comments