Skip to content
This repository has been archived by the owner on Sep 12, 2022. It is now read-only.

Django tests fail when run consecutively #626

Conversation

cdosborn
Copy link
Contributor

@cdosborn cdosborn commented Jun 18, 2018

Description

Fix test failures when run consecutively

Problem

Running tests twice causes failures

Solution

Remove the memoize cache before test runs

This would fail if run twice:

./manage.py test --keepdb jetstream.test_tas_api.TestJetstream.test_validate_account

It would fail because the cassettes did not reflect the correct number of plays, i.e. api calls didn't happen like we expected. Normally cassettes store the results of a first http call, and intercept and respond to all future calls with the results of the first. We assert that the cassette was called a certain number of times. However, django-memoize intercepts the functions that would even make these http calls, so the cassettes were under-reporting the number of playbacks.

Checklist before merging Pull Requests

  • Add an entry in the changelog
  • Reviewed and approved by at least one other contributor.

Problem:
Running tests twice causes failures

Solution:
Remove the memoize cache before test runs

This would fail if run twice:
./manage.py test --keepdb jetstream.test_tas_api.TestJetstream.test_validate_account

It would fail because the cassettes did not reflect the correct number of
plays, i.e. api calls didn't happen like we expected. Normally cassettes store
the results of a first http call, and intercept and respond to all future calls with the
results of the first. We assert that the cassette was called a certain number
of times. However, django-memoize intercepts the functions that would even
make these http calls, so the cassettes were under-reporting the number of
playbacks.
@cdosborn cdosborn self-assigned this Jun 18, 2018
@cdosborn
Copy link
Contributor Author

Related #511

@coveralls
Copy link

coveralls commented Jun 18, 2018

Coverage Status

Coverage increased (+0.007%) to 37.376% when pulling 73e7a0e on cdosborn:disable-cache-to-correctly-test-cassette-playback into a4d9862 on cyverse:master.

Copy link
Contributor

@julianpistorius julianpistorius left a comment

Choose a reason for hiding this comment

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

🎉

@cdosborn cdosborn merged commit 79dda5e into cyverse:master Jun 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants