mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-21 19:07:44 +01:00
pep8-fy tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
import mock
|
||||
from headphones.unittestcompat import TestCase
|
||||
from mock import MagicMock
|
||||
#from mock import MagicMock
|
||||
|
||||
from headphones.softchroot import SoftChroot
|
||||
from headphones.exceptions import SoftChrootError
|
||||
@@ -13,11 +13,10 @@ class SoftChrootTest(TestCase):
|
||||
cf = SoftChroot('/tmp/')
|
||||
self.assertIsInstance(cf, SoftChroot)
|
||||
|
||||
@mock.patch('headphones.config.ConfigObj', name='ConfigObjMock')
|
||||
def test_create_on_file(self, config_obj_fabric_mock):
|
||||
""" create SoftChroot on file, not a directory """
|
||||
def test_create_on_not_exists_dir(self):
|
||||
""" create SoftChroot on non existent dir """
|
||||
|
||||
path = os.path.join('tmp', 'notexist', 'asdf', '11', '12', 'np', 'itsssss')
|
||||
path = os.path.join('/tmp', 'notexist', 'asdf', '11', '12', 'np', 'itsssss')
|
||||
|
||||
with self.assertRaises(SoftChrootError) as exc:
|
||||
cf = SoftChroot(path)
|
||||
@@ -25,14 +24,19 @@ class SoftChrootTest(TestCase):
|
||||
self.assertRegexpMatches(str(exc.exception), r'No such directory')
|
||||
self.assertRegexpMatches(str(exc.exception), path)
|
||||
|
||||
@mock.patch('headphones.softchroot', name='SoftChrootMock')
|
||||
def test_create_on_file(self, config_obj_fabric_mock):
|
||||
@mock.patch('headphones.softchroot.os', wrap=os, name='OsMock')
|
||||
def test_create_on_file(self, os_mock):
|
||||
""" create SoftChroot on file, not a directory """
|
||||
|
||||
path = os.path.join('tmp', 'notexist', 'asdf', '11', '12', 'np', 'itsssss')
|
||||
path = os.path.join('/tmp', 'notexist', 'asdf', '11', '12', 'np', 'itsssss')
|
||||
|
||||
os_mock.path.sep = os.path.sep
|
||||
os_mock.path.isdir.side_effect = lambda x: x != path
|
||||
|
||||
with self.assertRaises(SoftChrootError) as exc:
|
||||
cf = SoftChroot(path)
|
||||
cf = SoftChroot(str(path))
|
||||
|
||||
self.assertTrue(os_mock.path.isdir.called)
|
||||
|
||||
self.assertRegexpMatches(str(exc.exception), r'No such directory')
|
||||
self.assertRegexpMatches(str(exc.exception), path)
|
||||
|
||||
Reference in New Issue
Block a user