Skip to content

py3 - testlinkapigeneric_online_test under py34 - attachment tests raise TypeError: expected bytes-like object, not str #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lczub opened this issue Nov 24, 2014 · 3 comments
Milestone

Comments

@lczub
Copy link
Owner

lczub commented Nov 24, 2014

Under py341, the attachment related unit tests in

raises a TypeError: expected bytes-like object, not str

affected test are:

  • test_uploadAttachment_unknownID
  • test_uploadExecutionAttachment_unknownID
  • test_uploadRequirementAttachment_unknownID
  • test_uploadRequirementSpecificationAttachment_unknownID
  • test_uploadTestCaseAttachment_unknownID
  • test_uploadTestProjectAttachment_unknownID
  • test_uploadTestSuiteAttachment_unknownID

Example

ERROR: test_uploadAttachment_unknownID (utest-online.testlinkapigeneric_online_test.TestLinkAPIOnlineTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\Programme\Python34\lib\base64.py", line 519, in _input_type_check
    m = memoryview(s)
TypeError: memoryview: str object does not have the buffer interface

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Projekte\git\TestLink-API-Python-client\test\utest-online\testlinkapigeneric_online_test.py", line 267, in test_uploadAttachment_unknownID
    title='title 4713', description='descr. 4714')
  File "D:\Projekte\git\TestLink-API-Python-client\src\testlink\testlinkdecorators.py", line 156, in wrapperAddAttachment
    argsAttachment = self._getAttachmentArgs(attachmentfile)
  File "D:\Projekte\git\TestLink-API-Python-client\src\testlink\testlinkapigeneric.py", line 1241, in _getAttachmentArgs
    'content':base64.encodestring(attachmentfile.read())
  File "D:\Programme\Python34\lib\base64.py", line 548, in encodestring
    return encodebytes(s)
  File "D:\Programme\Python34\lib\base64.py", line 536, in encodebytes
    _input_type_check(s)
  File "D:\Programme\Python34\lib\base64.py", line 522, in _input_type_check
    raise TypeError(msg) from err
TypeError: expected bytes-like object, not str
@lczub lczub added this to the v0.6.0 milestone Nov 24, 2014
@lczub lczub mentioned this issue Nov 24, 2014
@kman0
Copy link

kman0 commented Nov 26, 2014

Fixed in #37

@lczub
Copy link
Owner Author

lczub commented Dec 23, 2014

duplicate of #39

lczub pushed a commit that referenced this issue Dec 24, 2014
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.
@lczub
Copy link
Owner Author

lczub commented Dec 29, 2014

fixed with release v0.6.0

@lczub lczub closed this as completed Dec 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants