mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-26 23:23:48 +00:00
* improved detection of inside-project environments * make list command faster (by only instantiating the spider manger) * print a warning when extensions (middlewares, etc) are disabled with a message on NotConfigured exception * assert that scrapy configuration hasn't been loaded in scrapyd.runner * simplified IgnoreRequest exception, to avoid loading settings when importing scrapy.exceptions * added test to make sure certain modules don't cause scrapy.conf module to be loaded, to ensure the scrapyd runner bootstraping performs properly
23 lines
639 B
Python
23 lines
639 B
Python
import sys
|
|
import unittest
|
|
|
|
class SettingsSafeModulesTest(unittest.TestCase):
|
|
|
|
# these modules must not load scrapy.conf
|
|
SETTINGS_SAFE_MODULES = [
|
|
'scrapy.utils.project',
|
|
'scrapy.utils.conf',
|
|
'scrapyd.interfaces',
|
|
'scrapyd.eggutils',
|
|
]
|
|
|
|
def test_modules_that_shouldnt_load_settings(self):
|
|
sys.modules.pop('scrapy.conf', None)
|
|
for m in self.SETTINGS_SAFE_MODULES:
|
|
__import__(m)
|
|
assert 'scrapy.conf' not in sys.modules, \
|
|
"Module %r must not cause the scrapy.conf module to be loaded" % m
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|