title: Environment inherited Base class condition
body: <p>I'm writing up some testing <code>modules</code> for a project I'm working on.  I'm relatively new to testing, and I'm struggling to test the inherited base class properly.</p>
  <h3>app/base.py</h3>
  <pre class="lang-py prettyprint-override"><code>#app/base.py
  import os
  ENV = os.getenv('ENV', 'development')
  
  class Base:
      &quot;&quot;&quot;BASE CLASS&quot;&quot;&quot;
      def __init__(self,config_data,...):...
      self._api = config_data[ENV]
  
      @property
      def stuff(self):...self.get_stuff()
  
  class Production(Base):
      &quot;&quot;&quot;PRODUCTION CLASS&quot;&quot;&quot;
      def get_stuff(self):...with request(...)
  
  class Development(Base):
      &quot;&quot;&quot;DEVELOPMENT CLASS&quot;&quot;&quot;
      def get_stuff(self):... with open(...)
          
  class BaseConfig(Production if ENV == 'production' else
                   (Development if ENV == 'development' else Base)):
      &quot;&quot;&quot;ENV BASECLASS&quot;&quot;&quot;
  </code></pre>
  <h3>app/api.py</h3>
  <pre class="lang-py prettyprint-override"><code># app/api.py
  from app.base import BaseConfig
  class API(BaseConfig):
      def __init__(self, **kwargs):
  
          with open('app/config.json', mode='r', encoding='UTF-8') as config_file:
              api_config: ConfigFile = json.load(config_file)
  
          super().__init__(api_config, kwargs)
     @property
     def response(self):
         return super().stuff
  </code></pre>
  <h3>tests/base_test.py</h3>
  <pre class="lang-py prettyprint-override"><code># tests/base_test.py
  from unittest import mock
  import pytest
  from app import base
  
  @mock.patch('app.base.ENV', 'production')
  def test_inherited_base():
      assert base.BaseConfig.__base__ == base.Production
  
  FAILED tests/base_test.py::test_inherited_base - AssertionError: assert &lt;class 'app.base.Development'&gt; == &lt;class 'app.base.Production'&gt;
  </code></pre>
  <p>I was not getting an assertion error when I tested the <code>self._api</code> values.  So I'm assuming that once I <code>import base</code> in my testing <code>module</code> I can not retro actively set the inherited base statement.</p>