diff --git a/configurations/__main__.py b/configurations/__main__.py new file mode 100644 index 0000000..871ecc2 --- /dev/null +++ b/configurations/__main__.py @@ -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() diff --git a/tests/test_main.py b/tests/test_main.py index 7cbedbe..7f0a786 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -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__),