Skip to content

Commit

Permalink
Added "python -m configurations" entry point.
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert authored and auvipy committed Oct 27, 2021
1 parent 1dce659 commit 089a039
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions configurations/__main__.py
Original file line number Diff line number Diff line change
@@ -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()
16 changes: 16 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ def test_configuration_argument_in_cli(self):
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__),
Expand Down

0 comments on commit 089a039

Please sign in to comment.