ROS-TCP-Endpoint icon indicating copy to clipboard operation
ROS-TCP-Endpoint copied to clipboard

fixed mock.called_once bugs

Open StephanHasler opened this issue 3 years ago • 1 comments

Proposed change(s)

In the test code several 'assert_called_once' have been replaced by 'assert_called_once()'. Doing so revealed another bug. Following change was necessary

mock_sys_modules.assert_called_once()  # bug: sys.modules["foo"] does not call the mock
mock_sys_modules.__getitem__.assert_called_once() # correct: it calls the mocks's __getitem__ instead

Useful links (GitHub issues, JIRA tickets, forum threads, etc.)

This fixes #121

Types of change(s)

  • [X] Bug fix
  • [ ] New feature
  • [ ] Code refactor
  • [ ] Documentation update
  • [ ] Other (please describe)

Testing and Verification

The unit tests have been executed like:

ROS-TCP-Endpoint/test>python -m pytest test*.py

All 38 tests passed.

Please describe the tests that you ran to verify your changes. Please also provide instructions, ROS packages, and Unity project files as appropriate so we can reproduce the test environment.

Test Configuration:

  • ROS Ubuntu 20.04, ROS Noetic

Checklist

  • [X] Ensured this PR is up-to-date with the dev branch
  • [X] Created this PR to target the dev branch
  • [X] Followed the style guidelines as described in the Contribution Guidelines
  • [ ] Added tests that prove my fix is effective or that my feature works
  • [ ] Updated the Changelog and described changes in the Unreleased section
  • [ ] Updated the documentation as appropriate

Other comments

StephanHasler avatar Jan 17 '22 11:01 StephanHasler

CLA assistant check
All committers have signed the CLA.

unity-cla-assistant avatar Jan 17 '22 11:01 unity-cla-assistant