Skip to content
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

Await async handle_trap function in bgp trap tests #323

Merged

Conversation

johannaengland
Copy link
Contributor

Scope and purpose

I noticed that when running the testsuite I got the following pytest warnings:

tests/trapobservers/bgp_traps_test.py::TestBgpTrapObserver::test_when_trap_is_missing_required_varbinds_it_should_do_nothing
  /home/johanna/zino/tests/trapobservers/bgp_traps_test.py:34: RuntimeWarning: coroutine 'BgpTrapObserver.handle_trap' was never awaited
    observer.handle_trap(trap=backward_transition_trap)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/trapobservers/bgp_traps_test.py::TestBgpTrapObserver::test_when_trap_has_invalid_remote_addr_it_should_do_nothing
  /home/johanna/zino/tests/trapobservers/bgp_traps_test.py:45: RuntimeWarning: coroutine 'BgpTrapObserver.handle_trap' was never awaited
    observer.handle_trap(trap=backward_transition_trap)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

tests/trapobservers/bgp_traps_test.py::TestBgpTrapObserver::test_when_trap_has_invalid_oper_state_it_should_do_nothing
  /home/johanna/zino/tests/trapobservers/bgp_traps_test.py:56: RuntimeWarning: coroutine 'BgpTrapObserver.handle_trap' was never awaited
    observer.handle_trap(trap=backward_transition_trap)
  Enable tracemalloc to get traceback where the object was allocated.
  See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

This removes these warning by actually awaiting the async handle_trap function and marking the tests as async themselves.

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Zino can be found in the
README.

  • Added a changelog fragment for towncrier
    • this does not change any behavior, only corrects the way tests are run
  • Added/amended tests for new/changed code
    • well, the tests are what is changed
  • Added/changed documentation
  • Linted/formatted the code with black, ruff and isort, easiest by using pre-commit
  • The first line of the commit message continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done

@johannaengland johannaengland self-assigned this Jul 24, 2024
Copy link

@johannaengland johannaengland merged commit 3ec4faf into Uninett:master Aug 20, 2024
9 of 10 checks passed
@johannaengland johannaengland deleted the tests/await-in-bgp-trap-tests branch August 20, 2024 12:58
Copy link

codecov bot commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.45%. Comparing base (395ac8e) to head (712a09d).
Report is 63 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #323      +/-   ##
==========================================
+ Coverage   97.32%   97.45%   +0.13%     
==========================================
  Files          64       64              
  Lines        7919     7919              
==========================================
+ Hits         7707     7717      +10     
+ Misses        212      202      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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