Skip to content
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

fix "too many open files" when running tests #696

Merged
merged 3 commits into from
Jul 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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