Closed vlieven closed 1 year ago
Ah, this is so great-- I ran into this bug myself last night when I was working on my remote environment branch and I said to myself "hmm, probably time to add pytest profiles" right before I went to sleep. Thank you @vlieven!
Happy to help! Should I update the tox and workflow, or how do you want to proceed?
@vlieven if you don't mind updating the workflow, I would be grateful-- also happy to do it myself (read: have ChatGPT do it for me)
Realizing it's pretty late in Belgium, gonna go the merge-and-chatgpt-it route
I noticed that the tests are only run against a
:memory:
database. This PR modifies the tests according to the dbt documentation to add testing profiles, allowing to switch between an in-memory and file-backed DuckDB backend (memory is kept as the default). The test can be run using a file by runningpytest --profile file
.This change surfaces a bug in the Environment class, where the connection is prematurely closed due to the
handles
counting. I think that theEnvironment.close(cursor)
behaviour is unwanted both for memory as file databases, which would make the handle counting unneeded as well. I simplified the implementation, fixing the issue, but I'm not sure if the handle counting served another purpose?I suppose the
tox.ini
and github workflows should be updated as well to include the second testing path, but I'll let you review these changes first. Thanks!