Skip to content

Commit

Permalink
fix "too many open files" when running tests (#696)
Browse files Browse the repository at this point in the history
* fix

* ci

* fix
  • Loading branch information
edublancas authored Jul 3, 2023
1 parent 9a8aeae commit 2456382
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from traitlets.config import Config
import os
import urllib.request
from pathlib import Path

import pytest
from IPython.core.interactiveshell import InteractiveShell


from sql.magic import SqlMagic, RenderMagic
from sql.magic_plot import SqlPlotMagic
from sql.magic_cmd import SqlCmdMagic
Expand Down Expand Up @@ -50,7 +52,14 @@ def clean_conns():

@pytest.fixture
def ip_empty():
ip_session = InteractiveShell()
c = Config()
# By default, InteractiveShell will record command's history in a SQLite database
# which leads to "too many open files" error when running tests; this setting
# disables the history recording.
# https://ipython.readthedocs.io/en/stable/config/options/terminal.html#configtrait-HistoryAccessor.enabled
c.HistoryAccessor.enabled = False
ip_session = InteractiveShell(config=c)

ip_session.register_magics(SqlMagic)
ip_session.register_magics(RenderMagic)
ip_session.register_magics(SqlPlotMagic)
Expand Down Expand Up @@ -107,6 +116,7 @@ def tmp_empty(tmp_path):
Create temporary path using pytest native fixture,
them move it, yield, and restore the original path
"""

old = os.getcwd()
os.chdir(str(tmp_path))
yield str(Path(tmp_path).resolve())
Expand Down

0 comments on commit 2456382

Please sign in to comment.