mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
parent
fca3ef8cf2
commit
eebd1a26ae
2 changed files with 5 additions and 24 deletions
|
|
@ -3,7 +3,6 @@ import pytest
|
|||
import sys
|
||||
from unittest.mock import MagicMock, call
|
||||
from sqlite_utils.utils import sqlite3
|
||||
from sqlite_utils.db import FunctionAlreadyRegistered
|
||||
|
||||
|
||||
def test_register_function(fresh_db):
|
||||
|
|
@ -85,12 +84,10 @@ def test_register_function_replace(fresh_db):
|
|||
|
||||
assert "one" == fresh_db.execute("select one()").fetchone()[0]
|
||||
|
||||
# This will fail to replace the function:
|
||||
with pytest.raises(FunctionAlreadyRegistered):
|
||||
|
||||
@fresh_db.register_function()
|
||||
def one(): # noqa
|
||||
return "two"
|
||||
# This will silently fail to replaec the function
|
||||
@fresh_db.register_function()
|
||||
def one(): # noqa
|
||||
return "two"
|
||||
|
||||
assert "one" == fresh_db.execute("select one()").fetchone()[0]
|
||||
|
||||
|
|
@ -100,12 +97,3 @@ def test_register_function_replace(fresh_db):
|
|||
return "two"
|
||||
|
||||
assert "two" == fresh_db.execute("select one()").fetchone()[0]
|
||||
|
||||
|
||||
def test_register_function_duplicate(fresh_db):
|
||||
def to_lower(s):
|
||||
return s.lower()
|
||||
|
||||
fresh_db.register_function(to_lower)
|
||||
with pytest.raises(FunctionAlreadyRegistered):
|
||||
fresh_db.register_function(to_lower)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue