with unit test and corrected function detection on the closure add a type impor tthough...
This commit is contained in:
parent
a640affc81
commit
fc281224cb
|
@ -35,6 +35,7 @@ __license__ = 'MIT'
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import inspect
|
import inspect
|
||||||
import bottle
|
import bottle
|
||||||
|
import types
|
||||||
|
|
||||||
# PluginError is defined to bottle >= 0.10
|
# PluginError is defined to bottle >= 0.10
|
||||||
if not hasattr(bottle, 'PluginError'):
|
if not hasattr(bottle, 'PluginError'):
|
||||||
|
@ -106,9 +107,10 @@ class SQLitePlugin(object):
|
||||||
if keyword not in argspec.args:
|
if keyword not in argspec.args:
|
||||||
#check for closure
|
#check for closure
|
||||||
no_keyword_arg = True
|
no_keyword_arg = True
|
||||||
|
if _callback.func_closure is not None:
|
||||||
for closure in _callback.func_closure:
|
for closure in _callback.func_closure:
|
||||||
contents = closure.cell_contents
|
contents = closure.cell_contents
|
||||||
if callable(contents):
|
if isinstance(contents, types.FunctionType):
|
||||||
argspec = inspect.getargspec(contents)
|
argspec = inspect.getargspec(contents)
|
||||||
if keyword in argspec.args:
|
if keyword in argspec.args:
|
||||||
no_keyword_arg = False
|
no_keyword_arg = False
|
||||||
|
|
7
test.py
7
test.py
|
@ -28,6 +28,13 @@ class SQLiteTest(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
os.unlink(self.plugin.dbfile)
|
os.unlink(self.plugin.dbfile)
|
||||||
|
|
||||||
|
def test_with_view(self):
|
||||||
|
@self.app.get('/')
|
||||||
|
@bottle.view('test_view')
|
||||||
|
def test(db):
|
||||||
|
self.assertEqual(type(db), type(sqlite3.connect(':memory:')))
|
||||||
|
self._request('/')
|
||||||
|
|
||||||
def test_with_keyword(self):
|
def test_with_keyword(self):
|
||||||
@self.app.get('/')
|
@self.app.get('/')
|
||||||
def test(db):
|
def test(db):
|
||||||
|
|
1
views/test_view.tpl
Normal file
1
views/test_view.tpl
Normal file
|
@ -0,0 +1 @@
|
||||||
|
test_view
|
Loading…
Reference in New Issue
Block a user