Skip to content

Conversation

@sveinse
Copy link
Collaborator

@sveinse sveinse commented Jun 15, 2025

The test test_block_download_not_supported is creating warnings from pytest

test/test_local.py::TestSDO::test_block_download_not_supported
  C:\Svein\canopen\venv\Lib\site-packages\_pytest\unraisableexception.py:85: PytestUnraisableExceptionWarning: Exception ignored in: <canopen.sdo.client.BlockDownloadStream object at 0x000001DA52BA6350>

  canopen.sdo.exceptions.SdoAbortedError: Code 0x05040001, Unknown SDO command specified

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "C:\Svein\canopen\canopen\sdo\client.py", line 794, in close
      if self.crc_supported:
         ^^^^^^^^^^^^^^^^^^
  AttributeError: 'BlockDownloadStream' object has no attribute 'crc_supported'

def test_block_download_not_supported(self):
data = b"TEST DEVICE"
with self.assertRaises(canopen.SdoAbortedError) as context:
with self.remote_node.sdo[0x1008].open('wb',
size=len(data),
block_transfer=True) as fp:
pass
self.assertEqual(context.exception.code, 0x05040001)

This PR fixes the issue. The problem was 2-fold.

  • The test tries to use a block download, which SdoServer.block_download() handles by sending an SDO abort. However, sending the abort fails, because SdoServer.abort() requires self._index and self._subindex.
  • The SdoClient.open() opens a BlockDownloadStream(), but it doesn't get to initialize fully before the effort is aborted. When the object is closed, it fails as it's left in limbo.

@codecov
Copy link

codecov bot commented Jun 15, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
canopen/sdo/client.py 50.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Member

@acolomb acolomb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find and looks like an appropriate fix. Just one minor, optional suggestion.

Co-authored-by: André Colomb <github.com@andre.colomb.de>
@sveinse sveinse merged commit 8d9aa6c into canopen-python:master Jun 18, 2025
3 of 4 checks passed
@sveinse sveinse deleted the feature-fix-testing-warnings branch June 18, 2025 15:14
@acolomb
Copy link
Member

acolomb commented Jun 18, 2025

Seems like merging was allowed for you in this case. I didn't change anything though since the last PR. Hope it stays OK now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants