Remove unused project path util function

This commit is contained in:
Jakob de Maeyer 2015-11-09 11:22:24 +01:00
parent b7b00fb956
commit 33dfb3e167
2 changed files with 0 additions and 39 deletions

View File

@ -71,15 +71,3 @@ def get_project_settings():
settings.setdict(env_overrides, priority='project')
return settings
def get_project_path():
"""Return the Python path of the current project.
This fails when the settings module does not live in the project's root.
"""
if not inside_project():
raise NotConfigured("Not inside a project")
settings_module_path = os.environ.get(ENVVAR)
if not settings_module_path:
raise NotConfigured("Unable to locate project's python path")
return settings_module_path.rsplit('.', 1)[0]

View File

@ -1,27 +0,0 @@
import os
from tests import mock
import unittest
from scrapy.exceptions import NotConfigured
from scrapy.utils.project import get_project_path, inside_project
class UtilsProjectTestCase(unittest.TestCase):
@mock.patch('scrapy.utils.project.inside_project', return_value=True)
def test_get_project_path(self, mock_ip):
def _test(settingsmod, expected):
with mock.patch.dict('os.environ',
{'SCRAPY_SETTINGS_MODULE': settingsmod}):
self.assertEqual(get_project_path(), expected)
_test('project.settings', 'project')
_test('project.othername', 'project')
_test('nested.project.settings', 'nested.project')
with mock.patch.dict('os.environ', {}, clear=True):
self.assertRaises(NotConfigured, get_project_path)
mock_ip.return_value = False
with mock.patch.dict('os.environ',
{'SCRAPY_SETTINGS_MODULE': 'some.settings'}):
self.assertRaises(NotConfigured, get_project_path)