title: Pytest + ModuleNotFoundError: No module named 'project_name.settings'
body: <p>I'm trying to test a scrapy spider using pytest. I'd like to make sure that a certain spider say, X, has been generated with that specific name. I can acess scrapy spiders from a script using the following code fragment:</p>
  
  <pre><code>from scrapy.crawler import CrawlerProcess
  from scrapy.utils.project import get_project_settings
  process = CrawlerProcess(get_project_settings())
  spiders =  list(process.spiders._spiders.keys())
  </code></pre>
  
  <p>However, when I'm trying to run this very same code fragment in pytest I get an error:</p>
  
  <pre><code>ModuleNotFoundError: No module named 'project_name.settings'
  </code></pre>
  
  <p>My project directory is as follows. </p>
  
  <pre><code>**project_name**
  ├── __init__.py
  ├── scrapy.cfg
  ├── setup.py
  ├── **project_name**
  │   ├── cli
  │   ├── conftest.py
      ├── __init__.py
      ├── settings.py
      ├── spiders
      ├── tests
         ├── unit
  </code></pre>
  
  <p>I think the problem comes from the way I created my pip package because scrapy's <code>get_project_settings()</code> is requesting for the <code>project_name.settings</code> module that has been "remapped" in setup.py from  <code>project_name.project_name.settings</code> but pytest does not know where to find that <code>project_name.settings</code>. It can see it if it's <code>project_name.project_name.settings</code> but not otherwise. This is my setup.py: </p>
  
  <pre><code>from setuptools import setup
  from setuptools import find_packages
  
  setup(
      name='project_name',
      description='',
      version='0.1',
      packages=find_packages(),
  )
  </code></pre>
  
  <p>Now, I don't know how to get pytest to understand that <code>project_name.settings</code> actually means <code>project_name.project_name.settings</code> using, I guess, setup.py or pytest plugins. Can someone help?</p>