mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 08:40:06 +08:00
35 lines
658 B
Python
35 lines
658 B
Python
|
import os
|
||
|
import sys
|
||
|
|
||
|
import pytest
|
||
|
|
||
|
|
||
|
source_path = os.path.join(
|
||
|
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'pythonx')
|
||
|
sys.path.append(source_path)
|
||
|
|
||
|
|
||
|
class VimStub(object):
|
||
|
def __init__(self):
|
||
|
self.executed_commands = []
|
||
|
|
||
|
def command(self, cmd):
|
||
|
self.executed_commands.append(cmd)
|
||
|
|
||
|
|
||
|
try:
|
||
|
import vim
|
||
|
except ImportError:
|
||
|
sys.modules['vim'] = VimStub()
|
||
|
else: # pragma: nocover
|
||
|
del vim
|
||
|
|
||
|
|
||
|
@pytest.fixture(autouse=True)
|
||
|
def vim(monkeypatch):
|
||
|
import python_imports as mod
|
||
|
stub = VimStub()
|
||
|
monkeypatch.setitem(sys.modules, 'vim', stub)
|
||
|
monkeypatch.setattr(mod, 'vim', stub)
|
||
|
return stub
|