You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While I was messing about with the JSON serialization, where I changed the default to json, the fourth assertion in this test started randomly failing. I fixed this, because it was caused by me when I was integrating #209 into the fork. However, I couldn't help but notice the highlighted line for assertion 3, and wonder why it was selecting item [0] which seemed to be different to the rest of the assertions. Surely if we are getting the data from test_client "cached" or not, we shouldn't assert differently from looking at this test.
I printed all the responses and the one which stood out was the line highlighted, it printed 1 (an int) while the other lines printed a float number, every time I ran the test it was the same. Printing item[0] other x_time variables and you get 1, so the third assertion if 1 != <floating point> is likely to always pass.
Additionally, none of the code inside the redefined functions view_works changes throughout any of the tests, and when you inspect the actual value for third_time you find it is the same as first_time and so the test would always assert true because the function never changes and the third result designed to catch it doesn't have the correct assertion.
flask-caching/tests/test_view.py
Line 413 in 7944b57
While I was messing about with the JSON serialization, where I changed the default to
json
, the fourth assertion in this test started randomly failing. I fixed this, because it was caused by me when I was integrating #209 into the fork. However, I couldn't help but notice the highlighted line for assertion 3, and wonder why it was selecting item [0] which seemed to be different to the rest of the assertions. Surely if we are getting the data from test_client "cached" or not, we shouldn't assert differently from looking at this test.I printed all the responses and the one which stood out was the line highlighted, it printed
1
(an int) while the other lines printed a float number, every time I ran the test it was the same. Printing item[0] otherx_time
variables and you get1
, so the third assertionif 1 != <floating point>
is likely to always pass.Additionally, none of the code inside the redefined functions
view_works
changes throughout any of the tests, and when you inspect the actual value forthird_time
you find it is the same asfirst_time
and so the test would always assert true because the function never changes and the third result designed to catch it doesn't have the correct assertion.To fix this, I changed it to using datetime and timedelta: https://github.com/NotoriousPyro/flask-caching-json/blob/591f89e4f09e90aad25b7027672d342c41349426/tests/test_view.py#L444
And now we can assert on the real returned value: https://github.com/NotoriousPyro/flask-caching-json/blob/591f89e4f09e90aad25b7027672d342c41349426/tests/test_view.py#L457
The text was updated successfully, but these errors were encountered: