import glob
import os
import importlib

import pytest


@pytest.fixture(params=glob.glob('ideascube/conf/*.py'))
def setting_module(request):
    basename = os.path.basename(request.param)

    module, _ = os.path.splitext(basename)
    return '.conf.%s' % module


def test_setting_file(setting_module):
    from ideascube.forms import UserImportForm

    settings = importlib.import_module(setting_module, package="ideascube")

    assert isinstance(getattr(settings, 'IDEASCUBE_NAME', ''), str)

    for name, _ in getattr(settings, 'USER_IMPORT_FORMATS', []):
        assert hasattr(UserImportForm, '_get_{}_mapping'.format(name))
        assert hasattr(UserImportForm, '_get_{}_reader'.format(name))

import glob
import os
import importlib

import pytest


@pytest.fixture(params=sorted([
    f for f in glob.glob('ideascube/conf/*.py')
    if not f.endswith('/__init__.py')
]))
def setting_module(request):
    basename = os.path.basename(request.param)

    module, _ = os.path.splitext(basename)
    return '.conf.%s' % module


def test_setting_file(setting_module):
    from ideascube.forms import UserImportForm

    settings = importlib.import_module(setting_module, package="ideascube")

    assert isinstance(getattr(settings, 'IDEASCUBE_NAME', ''), str)

    for name, _ in getattr(settings, 'USER_IMPORT_FORMATS', []):
        assert hasattr(UserImportForm, '_get_{}_mapping'.format(name))
        assert hasattr(UserImportForm, '_get_{}_reader'.format(name))

Improve the settings files testing fixture
tests: Improve the settings files testing fixture

Let's order these files, as it makes it nicer in the pytest output.

In addition, we can filter out the __init__.py file, since it is
completely empty.

  import glob
  import os
  import importlib
  
  import pytest
  
  
- @pytest.fixture(params=glob.glob('ideascube/conf/*.py'))
+ @pytest.fixture(params=sorted([
+     f for f in glob.glob('ideascube/conf/*.py')
+     if not f.endswith('/__init__.py')
+ ]))
  def setting_module(request):
      basename = os.path.basename(request.param)
  
      module, _ = os.path.splitext(basename)
      return '.conf.%s' % module
  
  
  def test_setting_file(setting_module):
      from ideascube.forms import UserImportForm
  
      settings = importlib.import_module(setting_module, package="ideascube")
  
      assert isinstance(getattr(settings, 'IDEASCUBE_NAME', ''), str)
  
      for name, _ in getattr(settings, 'USER_IMPORT_FORMATS', []):
          assert hasattr(UserImportForm, '_get_{}_mapping'.format(name))
          assert hasattr(UserImportForm, '_get_{}_reader'.format(name))
  
Improve the settings files testing fixture
## Code Before:
import glob
import os
import importlib

import pytest


@pytest.fixture(params=glob.glob('ideascube/conf/*.py'))
def setting_module(request):
    basename = os.path.basename(request.param)

    module, _ = os.path.splitext(basename)
    return '.conf.%s' % module


def test_setting_file(setting_module):
    from ideascube.forms import UserImportForm

    settings = importlib.import_module(setting_module, package="ideascube")

    assert isinstance(getattr(settings, 'IDEASCUBE_NAME', ''), str)

    for name, _ in getattr(settings, 'USER_IMPORT_FORMATS', []):
        assert hasattr(UserImportForm, '_get_{}_mapping'.format(name))
        assert hasattr(UserImportForm, '_get_{}_reader'.format(name))

## Instruction:
Improve the settings files testing fixture
## Code After:
import glob
import os
import importlib

import pytest


@pytest.fixture(params=sorted([
    f for f in glob.glob('ideascube/conf/*.py')
    if not f.endswith('/__init__.py')
]))
def setting_module(request):
    basename = os.path.basename(request.param)

    module, _ = os.path.splitext(basename)
    return '.conf.%s' % module


def test_setting_file(setting_module):
    from ideascube.forms import UserImportForm

    settings = importlib.import_module(setting_module, package="ideascube")

    assert isinstance(getattr(settings, 'IDEASCUBE_NAME', ''), str)

    for name, _ in getattr(settings, 'USER_IMPORT_FORMATS', []):
        assert hasattr(UserImportForm, '_get_{}_mapping'.format(name))
        assert hasattr(UserImportForm, '_get_{}_reader'.format(name))
