Skip to content

Commit

Permalink
fix: testing fix 101
Browse files Browse the repository at this point in the history
  • Loading branch information
mfarhan943 committed Oct 14, 2024
1 parent 5b80967 commit 37772e8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
39 changes: 38 additions & 1 deletion pylint_django_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,42 @@ def open(self):
name_checker.config.django_settings_module = 'lms.envs.test'


def _get_django_settings_module(arguments):
# pylint command should not run with modules from both cms and (lms, common) at once
cms_module = False
lms_module = False
common_module = False

for arg in arguments:
if arg.startswith('cms'):
cms_module = True
elif arg.startswith('lms'):
lms_module = True
elif arg.startswith('common'):
common_module = True

if cms_module and (lms_module or common_module):
# when cms module is present in pylint command, it can't be parired with (lms, common)
# as common and lms gives error with cms test settings
raise ArgumentCompatibilityError(
"Modules from both common and lms can't be paired with cms while running pylint"
)
elif cms_module:
# If a module from cms is present in pylint command arguments
# and ony other module from (openedx, pavelib) is present
# than test setting of cms is used
return 'cms.envs.test'
else:
# If any module form (lms, common, openedx, pavelib) is present in
# pylint command arguments than test setting of lms is used
return 'lms.envs.test'


def register(linter):
linter.register_checker(SetDjangoSettingsChecker(linter))
"""Required function to register the plugin."""
pass


def load_configuration(linter):
name_checker = get_checker(linter, ForeignKeyStringsChecker)
name_checker.config.django_settings_module = _get_django_settings_module(linter.cmdline_parser.parse_args()[1])
10 changes: 5 additions & 5 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@
# SERIOUSLY.
#
# ------------------------------
# Generated by edx-lint version: 5.3.0
# Generated by edx-lint version: 5.3.7
# ------------------------------
[MASTER]
ignore = ,.git,.tox,migrations,node_modules,.pycharm_helpers
persistent = yes
load-plugins = edx_lint.pylint,pylint_django,pylint_celery,pylint_pytest
load-plugins = edx_lint.pylint,pylint_django_settings,pylint_django,pylint_celery,pylint_pytest

[MESSAGES CONTROL]
enable =
blacklisted-name,
line-too-long,

abstract-class-instantiated,
abstract-method,
access-member-before-definition,
Expand Down Expand Up @@ -407,6 +407,6 @@ ext-import-graph =
int-import-graph =

[EXCEPTIONS]
overgeneral-exceptions = Exception
overgeneral-exceptions = builtins.Exception

# 567bf30b121db79bc07a7028651f7efa0724e8a4
# e624ea03d8124aa9cf2e577f830632344a0a07d9
2 changes: 1 addition & 1 deletion pylintrc_tweaks
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylintrc tweaks for use with edx_lint.
[MASTER]
ignore+ = ,.git,.tox,migrations,node_modules,.pycharm_helpers
load-plugins = edx_lint.pylint,pylint_django,pylint_celery,pylint_pytest
load-plugins = edx_lint.pylint,pylint_django_settings,pylint_django,pylint_celery,pylint_pytest

[MESSAGES CONTROL]
disable+ =
Expand Down

0 comments on commit 37772e8

Please sign in to comment.