-
-
Notifications
You must be signed in to change notification settings - Fork 122
Fix test to pass pytest -Werror
#623
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
Conversation
The first case is not the test you mark, but the previous test_upsert_pk_required. When you run the upsert "click" opens the file first but as it then gives the error "Error: Missing option '--pk" it doesn't close it correctly.
sqlite-utils/sqlite_utils/cli.py
Line 868 in 1d050dc
The solution is to pass lazy=True to the click.File so that it does not open it until it is necessary.
It seems that in test_memory_csv only for when use_stdin=False the io.TextIOWrapper on line 297 is not closed correctly.
sqlite-utils/sqlite_utils/utils.py
Lines 295 to 302 in 1d050dc
The only way I can think of is to pass the buffer to _extra_key_strategy and close it once the generator is finished, but surely there must be a nicer way.
Similar to the first case, it is not test_memory_dump but test_memory_csv_encoding the previous test that is the culprit, and also only when use_stdin=False.
It seems that when the enconding is wrong it raises a UnicodeDecodeError error when it tries to iterate over the generator from rows_from_file and that's why it doesn't reach the end to close the fp file.
sqlite-utils/sqlite_utils/cli.py
Lines 1949 to 1968 in 1d050dc
The only thing that I can think of is to catch the error, close the file and raise it again.
test_insert_files.py is a deprecation warning. datetime.utcfromtimestamp is replaced by datetime.fromtimestamp in py3.12, I pass the timezone to make sure it is utc (otherwise it grabs the local one) and stripe the timezone to be the same as it was before.
Uh oh!
There was an error while loading. Please reload this page.
Refs #541
Still TODO:
📚 Documentation preview 📚: https://sqlite-utils--623.org.readthedocs.build/en/623/