Moves TestFakeFs helper to fake_env module.
This commit is contained in:
parent
de3dda85d1
commit
93c7fb2f27
@ -3,16 +3,14 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import glob
|
import glob
|
||||||
import unittest
|
import unittest
|
||||||
import pkgutil
|
|
||||||
import re
|
|
||||||
|
|
||||||
import dotdot
|
import dotdot
|
||||||
import fake_filesystem
|
import fake_filesystem
|
||||||
import fake_filesystem_shutil
|
import fake_filesystem_shutil
|
||||||
import fake_filesystem_glob
|
import fake_filesystem_glob
|
||||||
|
|
||||||
from pubs import color
|
|
||||||
from pubs.p3 import io, input
|
from pubs.p3 import io, input
|
||||||
|
from pubs import content, filebroker
|
||||||
|
|
||||||
# code for fake fs
|
# code for fake fs
|
||||||
|
|
||||||
@ -48,12 +46,7 @@ def create_fake_fs(module_list):
|
|||||||
|
|
||||||
fake_fs.CreateDirectory(fake_os.path.expanduser('~'))
|
fake_fs.CreateDirectory(fake_os.path.expanduser('~'))
|
||||||
|
|
||||||
try:
|
__builtins__.update({'open': fake_open, 'file': fake_open})
|
||||||
__builtins__.open = fake_open
|
|
||||||
__builtins__.file = fake_open
|
|
||||||
except AttributeError:
|
|
||||||
__builtins__['open'] = fake_open
|
|
||||||
__builtins__['file'] = fake_open
|
|
||||||
|
|
||||||
sys.modules['os'] = fake_os
|
sys.modules['os'] = fake_os
|
||||||
sys.modules['shutil'] = fake_shutil
|
sys.modules['shutil'] = fake_shutil
|
||||||
@ -160,3 +153,12 @@ class FakeInput():
|
|||||||
self._cursor += 1
|
self._cursor += 1
|
||||||
return inp
|
return inp
|
||||||
|
|
||||||
|
|
||||||
|
class TestFakeFs(unittest.TestCase):
|
||||||
|
"""Abstract TestCase intializing the fake filesystem."""
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
self.fs = create_fake_fs([content, filebroker])
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
unset_fake_fs([content, filebroker])
|
||||||
|
@ -10,15 +10,6 @@ from pubs import content, filebroker, databroker, datacache
|
|||||||
import str_fixtures
|
import str_fixtures
|
||||||
from pubs import endecoder
|
from pubs import endecoder
|
||||||
|
|
||||||
class TestFakeFs(unittest.TestCase):
|
|
||||||
"""Abstract TestCase intializing the fake filesystem."""
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.fs = fake_env.create_fake_fs([content, filebroker])
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
fake_env.unset_fake_fs([content, filebroker])
|
|
||||||
|
|
||||||
|
|
||||||
class TestDataBroker(unittest.TestCase):
|
class TestDataBroker(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -7,17 +7,8 @@ import fake_env
|
|||||||
|
|
||||||
from pubs import content, filebroker
|
from pubs import content, filebroker
|
||||||
|
|
||||||
class TestFakeFs(unittest.TestCase):
|
|
||||||
"""Abstract TestCase intializing the fake filesystem."""
|
|
||||||
|
|
||||||
def setUp(self):
|
class TestFileBroker(fake_env.TestFakeFs):
|
||||||
self.fs = fake_env.create_fake_fs([content, filebroker])
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
fake_env.unset_fake_fs([content, filebroker])
|
|
||||||
|
|
||||||
|
|
||||||
class TestFileBroker(TestFakeFs):
|
|
||||||
|
|
||||||
def test_pushpull1(self):
|
def test_pushpull1(self):
|
||||||
|
|
||||||
@ -89,7 +80,7 @@ class TestFileBroker(TestFakeFs):
|
|||||||
self.assertFalse(fb.exists('citekey1'))
|
self.assertFalse(fb.exists('citekey1'))
|
||||||
|
|
||||||
|
|
||||||
class TestDocBroker(TestFakeFs):
|
class TestDocBroker(fake_env.TestFakeFs):
|
||||||
|
|
||||||
def test_doccopy(self):
|
def test_doccopy(self):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user