Permalink
Browse files

Also made a stub for the random function.

  • Loading branch information...
1 parent 5c2126c commit 06b445314bcdaa8ae8c8e041ab75749841672f45 @nvie committed Jul 29, 2010
Showing with 11 additions and 3 deletions.
  1. +4 −0 tests/test_vim_bridge.py
  2. +7 −3 vim_bridge/__init__.py
@@ -4,6 +4,10 @@
import sys
sys.path = ['tests/mocks'] + sys.path
+# Stub out the random function
+import vim_bridge
+vim_bridge._rand = lambda: 3
+
from vim_bridge import bridged
@@ -6,6 +6,12 @@
__version__ = ".".join(map(str, VERSION[0:2]))
+def _rand():
+ import random
+ random.seed()
+ return random.randint(1000, 9999)
+
+
def _upcase_first(s):
if len(s) == 0:
return s
@@ -47,9 +53,7 @@ def bridged(fin):
private, vimname = _convert_function_name(fin.func_name)
private = private and "s:" or ""
- import random
- random.seed()
- prefix = '__vim_brdg_%d_' % random.randint(1000, 9999)
+ prefix = '__vim_brdg_%d_' % _rand()
lines = ['fun! %s%s(%s)' % (private, vimname, ", ".join(func_args))]
lines.append('python << endp')

0 comments on commit 06b4453

Please sign in to comment.