Open lbellomo opened 6 months ago
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.
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.
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.
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.
Refs https://github.com/simonw/sqlite-utils/issues/541
Still TODO:
📚 Documentation preview 📚: https://sqlite-utils--623.org.readthedocs.build/en/623/