Refine tests
This commit is contained in:
+23
-25
@@ -1,32 +1,30 @@
|
||||
import pytest
|
||||
from mock import patch, Mock
|
||||
from mock import Mock
|
||||
from thefuck.history import History
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def process(monkeypatch):
|
||||
Process = Mock()
|
||||
Process.return_value.parent.return_value.pid = 1
|
||||
monkeypatch.setattr('thefuck.history.Process', Process)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def db(monkeypatch):
|
||||
class DBMock(dict):
|
||||
def __init__(self):
|
||||
super(DBMock, self).__init__()
|
||||
self.sync = Mock()
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self
|
||||
|
||||
db = DBMock()
|
||||
monkeypatch.setattr('thefuck.history.shelve.open', db)
|
||||
return db
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('process')
|
||||
class TestHistory(object):
|
||||
@pytest.fixture(autouse=True)
|
||||
def process(self, monkeypatch):
|
||||
Process = Mock()
|
||||
Process.return_value.parent.return_value.pid = 1
|
||||
monkeypatch.setattr('thefuck.history.Process', Process)
|
||||
return Process
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def db(self, monkeypatch):
|
||||
class DBMock(dict):
|
||||
def __init__(self):
|
||||
super(DBMock, self).__init__()
|
||||
self.sync = Mock()
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self
|
||||
|
||||
db = DBMock()
|
||||
monkeypatch.setattr('thefuck.history.shelve.open', db)
|
||||
return db
|
||||
|
||||
def test_set(self, db):
|
||||
history = History()
|
||||
history.update(last_script='ls',
|
||||
@@ -39,6 +37,6 @@ class TestHistory(object):
|
||||
db['1-last_script'] = 'cd ..'
|
||||
assert history.last_script == 'cd ..'
|
||||
|
||||
def test_get_without_value(self, db):
|
||||
def test_get_without_value(self):
|
||||
history = History()
|
||||
assert history.last_script is None
|
||||
|
||||
Reference in New Issue
Block a user