Skip to content

Commit

Permalink
fix: check in linux extensions; update test skip logic
Browse files Browse the repository at this point in the history
  • Loading branch information
tconbeer committed Apr 25, 2024
1 parent 1fbe6d4 commit f59c106
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ __pycache__/

# C extensions
*.so
!tests/data/**/*.so

# Distribution / packaging
.Python
Expand Down
9 changes: 5 additions & 4 deletions tests/adapter_tests/test_sqlite.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

import sys
import sqlite3
from pathlib import Path

import pytest
Expand Down Expand Up @@ -212,8 +212,8 @@ def test_rewrite_load(extension_path: Path) -> None:


@pytest.mark.skipif(
sys.platform != "win32",
reason="Default ubuntu and mac distributions disable sqlite3 extensions.",
not hasattr(sqlite3.Connection, "enable_load_extension"),
reason="Not supported on many Pythons.",
)
def test_load_extension(extension_path: Path) -> None:
conn = HarlequinSqliteAdapter(
Expand All @@ -223,7 +223,8 @@ def test_load_extension(extension_path: Path) -> None:


@pytest.mark.skipif(
sys.platform == "win32", reason="Windows supports sqlite extensions."
hasattr(sqlite3.Connection, "enable_load_extension"),
reason="Not supported on many Pythons.",
)
def test_load_extension_raises(extension_path: Path) -> None:
with pytest.raises(HarlequinConfigError) as exc_info:
Expand Down
Binary file not shown.
Binary file added tests/data/unit_tests/sqlite_extension/hello0.so
Binary file not shown.
11 changes: 6 additions & 5 deletions tests/unit_tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import hashlib
import json
import sys
import sqlite3
from pathlib import Path
from unittest.mock import MagicMock

Expand Down Expand Up @@ -312,9 +312,10 @@ def test_bad_config_exits(


@pytest.mark.skipif(
sys.platform != "win32", reason="Extension option only supported on Windows."
not hasattr(sqlite3.Connection, "enable_load_extension"),
reason="Extension option not supported on many pythons.",
)
def test_sqlite_extension_windows(
def test_sqlite_extensions(
mock_harlequin: MagicMock,
mock_sqlite_adapter: MagicMock,
mock_empty_config: None,
Expand All @@ -329,8 +330,8 @@ def test_sqlite_extension_windows(


@pytest.mark.skipif(
sys.platform == "win32",
reason="Extension option not supported on non-windows platforms.",
hasattr(sqlite3.Connection, "enable_load_extension"),
reason="Extension option not supported on many pythons.",
)
def test_sqlite_extension_not_supported(
mock_harlequin: MagicMock,
Expand Down

0 comments on commit f59c106

Please sign in to comment.