-
-
Notifications
You must be signed in to change notification settings - Fork 438
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
InterfaceError: Error binding parameter 1 - probably unsupported type. #1138
Comments
Thanks for the report. Is this reproducible for you? It looks like the "fix" for #1010 needs to be applied in another place, though you are not using PyPy, which was a key element in #1010. Can you try this patch?
Or you can try installing the fix from my branch:
|
@nedbat Thanks for the quick response. However, I still get an INTERNALERROR. What I did? I tried patching it by first pip uninstalling coverage and then installed coverage from your branch ( 5.5.1a0 ). Have you got any other insights as to how this can be fixed? See the logs:
|
It seems like you have an unusual situation. Can you give me a way to reproduce it? |
Though: the error you report here could just be that it's too simplistic to retry all of the statements in an Either way, it would be helpful to have a way to reproduce it. |
@nedbat Yes, absolutely. To reproduce, run the following commands for this dev branch https://github.com/felipejinli/onionbalance/tree/dev.
|
Thanks for the reproducible case. The problem is your mock of datetime.datetime in test_outdated_consensus. You never undo that mock, so datetime.datetime is a mock object for the rest of the test run. Coverage.py later tries to get the current time to put in its database, and gets a mock object instead of a timestamp. SQLite can't write the mock object to the database. The best thing to do would be to use mock.patch as a context manager instead. It will automatically clean up the mock at the end of the test: def test_outdated_consensus(self):
current_time = datetime.datetime.fromtimestamp(10101010101)
consensus = DummyConsensus()
consensus.consensus = mock.Mock()
with mock.patch("datetime.datetime") as mock_datetime:
consensus.consensus.valid_after = current_time
# valid_until is 3 hours in the future
consensus.consensus.valid_until = current_time + datetime.timedelta(seconds=3600*3)
# Test some legitimate cases
mock_datetime.utcnow.return_value = current_time
self.assertTrue(consensus.is_live())
mock_datetime.utcnow.return_value = current_time + datetime.timedelta(seconds=3600*11)
self.assertTrue(consensus.is_live())
mock_datetime.utcnow.return_value = current_time + datetime.timedelta(seconds=3600*12)
self.assertTrue(consensus.is_live())
mock_datetime.utcnow.return_value = current_time + datetime.timedelta(seconds=3600*24)
self.assertTrue(consensus.is_live())
mock_datetime.utcnow.return_value = current_time - datetime.timedelta(seconds=3600*24)
self.assertTrue(consensus.is_live())
# Now test some bad cases. The is_live() function is lenient up to 24
# hours after the valid_until, or 24 hours before the valid_after
mock_datetime.utcnow.return_value = consensus.consensus.valid_until + datetime.timedelta(seconds=3600*24+1)
self.assertFalse(consensus.is_live())
mock_datetime.utcnow.return_value = consensus.consensus.valid_after - datetime.timedelta(seconds=3600*24+1)
self.assertFalse(consensus.is_live()) As another tip: it's better to mock where you use an object, rather than where it is defined. That will limit the scope to just the code that needs the mock. That might be harder in this case, it looks like a few different places use utcnow. |
Describe the bug
When running pytest with the pytest-cov package (includes coveragepy), an INTERNALERROR is thrown. This looks similar to #1010 @nedbat , but it seems like the bug is still not fixed as my project is using v5.5.0 of coverage.
To Reproduce
Run command pytest --cov-report=term-missing --ignore=./test/functional/ --cov=onionbalance
NB. if the above command is ran without the cov option, no internal error is thrown, BUT the coverage report is not generated still
Expected behavior
I expected a coverage report to be generated without throwing an InternalError.
The text was updated successfully, but these errors were encountered: