Added "python -m configurations" entry point.

inspired by e0a46367df/django/__main__.py (L1-L9)

see also https://code.djangoproject.com/ticket/24857
This commit is contained in:
Thomas Grainger 2021-01-15 11:11:46 +00:00 committed by Asif Saif Uddin
parent 1dce659946
commit 089a039efa
2 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,10 @@
"""
invokes django-cadmin when the configurations module is run as a script.
Example: python -m configurations check
"""
from .management import execute_from_command_line
if __name__ == "__main__":
execute_from_command_line()

View file

@ -106,6 +106,22 @@ class MainTests(TestCase):
stdout=subprocess.PIPE)
self.assertIn('--configuration', proc.communicate()[0].decode('utf-8'))
def test_configuration_argument_in_runypy_cli(self):
"""
Verify that's configuration option has been added to managements
commands when using the -m entry point
"""
proc = subprocess.Popen(
[sys.executable, '-m', 'configurations', 'test', '--help'],
stdout=subprocess.PIPE,
)
self.assertIn('--configuration', proc.communicate()[0].decode('utf-8'))
proc = subprocess.Popen(
[sys.executable, '-m', 'configurations', 'runserver', '--help'],
stdout=subprocess.PIPE,
)
self.assertIn('--configuration', proc.communicate()[0].decode('utf-8'))
def test_django_setup_only_called_once(self):
proc = subprocess.Popen(
[sys.executable, os.path.join(os.path.dirname(__file__),