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

fix(79): Ensure tests supposed to fail also fail, when monitoring is disabled (--no-monitor cmd flag) #81

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lhpt2
Copy link

@lhpt2 lhpt2 commented May 8, 2024

Description

There was a bug that resulted in some tests not failing when the cmd flag --no-monitor is set. Raising a BaseException in the corresponding code that runs when monitoring is disabled (line 218 following) solves the issue.

Fixes #79

fix(79): Ensure test supposed to fail also fail, when monitoring is disabled (--no-monitor cmd flag)

changelog updated in this commit too

The issue was an exception not being raised when calling
wrapped_function when monitoring is disabled in line 216.
The raise is being handled now in the following lines 218ff.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
    - [ ] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
  • My changes generate no new warnings
    - [ ] I have added tests that prove my fix is effective or that my feature works
    - [] New and existing unit tests pass locally with my changes (not just the CI)
    - [ ] Any dependent changes have been merged and published in downstream modules
  • I have provided a link to the issue this PR adresses in the Description section above (If there is none yet,
    create one !)
  • I have updated the changelog
  • I have labeled my PR using appropriate tags (in particular using status labels like Status: Code Review Needed, Business: Test Needed or Status: In Progress if you are still working on the PR)

disabled (--no-monitor cmd flag)

changelog updated in this commit too

The issue was an exception not being raised when calling
wrapped_function when monitoring is disabled in line 216.
The raise is being handled now in the following lines 218ff.
Copy link

sonarcloud bot commented May 8, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
30.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@lhpt2 lhpt2 marked this pull request as draft May 8, 2024 12:51
@lhpt2 lhpt2 marked this pull request as ready for review May 8, 2024 13:15
@lhpt2
Copy link
Author

lhpt2 commented May 8, 2024

I'm not sure what SonarClouds wants to say with DuplicationOnNewCode or how I could resolve that.

@lhpt2 lhpt2 changed the title fix(79): Ensure test supposed to fail also fail, when monitoring is disabled (--no-monitor cmd flag) fix(79): Ensure tests supposed to fail also fail, when monitoring is disabled (--no-monitor cmd flag) May 8, 2024
Lucas Haupt added 3 commits July 3, 2024 15:49
Returning exceptions inside the wrapped_function() can lead to
assertions being ignored, therefore they need to be raised instantly
and parent calls need to wrap their call in a try except block.
The memory profiler only reports Exceptions when it should report all
Exceptions that inherit from BaseExceptions.

This is ultimately reworked in a PR incorporating a simplified
memory profiler module into the codebase that fixes not only this issue
but also gives the possibility of getting measurements for failing
tests.

This workaround uses return values to work around the issue. This way
pytest-monitor can check for BaseExceptions and act accordingly.
Like described earlier the ultimate goal should probably be to replace
the whole memory profiler as proposed in this PR:
CFMTech#82
@lhpt2
Copy link
Author

lhpt2 commented Jul 15, 2024

The newest commit is a bug fix introduced by the memory_profiler module, which doesn't catch all Exceptions (only checks for Exception not BaseException). Worked around this by returning the exception from the wrapped function. This is only a temporary workaround to make everything work, it should be considered to do it as in PR #82 and replace the whole memory profiler module in some way and fix the issues that way. The bug occurs on test runs and causes them to not finish but block execution from finishing.

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.

--no-monitor breaks pytest.raises and django_assert_num_queries
1 participant