Пример #1
0
 def test_script(self, execute_manager):
     # The test script should execute the standard Django test
     # command with any apps given as its arguments.
     test.main('cheeseshop.development',  'spamm', 'eggs')
     # We only care about the arguments given to execute_manager
     self.assertEqual(execute_manager.call_args[1], 
                      {'argv': ['test', 'test', 'spamm', 'eggs']})
Пример #2
0
 def test_script(self, execute_manager):
     # The test script should execute the standard Django test
     # command with any apps given as its arguments.
     from djangorecipe import test
     test.main('cheeseshop.development',  'spamm', 'eggs')
     # We only care about the arguments given to execute_manager
     self.assertEqual(execute_manager.call_args[1],
                      {'argv': ['test', 'test', 'spamm', 'eggs']})
Пример #3
0
    def test_script(self, mock_setdefault, execute_from_command_line):
        with mock.patch.object(sys, "argv", ["bin/test"]):
            # The test script should execute the standard Django test command
            # with any apps configured in djangorecipe given as its arguments.
            from djangorecipe import test

            test.main("cheeseshop.development", "spamm", "eggs")
            self.assertTrue(execute_from_command_line.called)
            self.assertEqual(execute_from_command_line.call_args[0], (["bin/test", "test", "spamm", "eggs"],))
            self.assertEqual(mock_setdefault.call_args[0], ("DJANGO_SETTINGS_MODULE", "cheeseshop.development"))
Пример #4
0
 def test_script(self, mock_setdefault, execute_from_command_line):
     # The test script should execute the standard Django test
     # command with any apps given as its arguments.
     from djangorecipe import test
     test.main('cheeseshop.development',  'spamm', 'eggs')
     # We only care about the arguments given to execute_from_command_line
     self.assertEqual(execute_from_command_line.call_args[0],
                      (['test', 'test', 'spamm', 'eggs'],))
     self.assertEqual(mock_setdefault.call_args[0],
                      ('DJANGO_SETTINGS_MODULE', 'cheeseshop.development'))
Пример #5
0
 def test_script(self, mock_setdefault, execute_from_command_line):
     # The test script should execute the standard Django test
     # command with any apps given as its arguments.
     from djangorecipe import test
     test.main('cheeseshop.development', 'spamm', 'eggs')
     # We only care about the arguments given to execute_from_command_line
     self.assertEqual(execute_from_command_line.call_args[0],
                      (['test', 'test', 'spamm', 'eggs'], ))
     self.assertEqual(mock_setdefault.call_args[0],
                      ('DJANGO_SETTINGS_MODULE', 'cheeseshop.development'))
Пример #6
0
 def test_script(self, mock_setdefault, execute_from_command_line):
     with mock.patch.object(sys, 'argv', ['bin/test']):
         # The test script should execute the standard Django test command
         # with any apps configured in djangorecipe given as its arguments.
         from djangorecipe import test
         test.main('cheeseshop.development',  'spamm', 'eggs')
         self.assertTrue(execute_from_command_line.called)
         self.assertEqual(execute_from_command_line.call_args[0],
                          (['bin/test', 'test', 'spamm', 'eggs'],))
         self.assertEqual(mock_setdefault.call_args[0],
                          ('DJANGO_SETTINGS_MODULE', 'cheeseshop.development'))
Пример #7
0
 def test_script_with_args(self, mock_setdefault, execute_from_command_line):
     with mock.patch.object(sys, 'argv', ['bin/test', '--verbose']):
         # The test script should execute the standard Django test command
         # with any apps given as its arguments. It should also pass along
         # command line arguments so that the actual test machinery can
         # pick them up (like '--verbose' or '--tests=xyz').
         from djangorecipe import test
         test.main('cheeseshop.development',  'spamm', 'eggs')
         self.assertEqual(execute_from_command_line.call_args[0],
                          (['bin/test', 'test', 'spamm', 'eggs', '--verbose'],))
         self.assertEqual(mock_setdefault.call_args[0],
                          ('DJANGO_SETTINGS_MODULE', 'cheeseshop.development'))
Пример #8
0
    def test_script_with_args(self, mock_setdefault, execute_from_command_line):
        with mock.patch.object(sys, "argv", ["bin/test", "--verbose"]):
            # The test script should execute the standard Django test command
            # with any apps given as its arguments. It should also pass along
            # command line arguments so that the actual test machinery can
            # pick them up (like '--verbose' or '--tests=xyz').
            from djangorecipe import test

            test.main("cheeseshop.development", "spamm", "eggs")
            self.assertEqual(
                execute_from_command_line.call_args[0], (["bin/test", "test", "spamm", "eggs", "--verbose"],)
            )
            self.assertEqual(mock_setdefault.call_args[0], ("DJANGO_SETTINGS_MODULE", "cheeseshop.development"))
Пример #9
0
 def test_deeply_nested_settings(self, execute_manager):
     # Settings files can be more than two levels deep. We need to
     # make sure the test script can properly import those. To
     # demonstrate this we need to add another level to our
     # sys.modules entries.
     settings = mock.sentinel.SettingsModule
     nce = mock.sentinel.NCE
     nce.development = settings
     sys.modules['cheeseshop'].nce = nce
     sys.modules['cheeseshop.nce'] = nce
     sys.modules['cheeseshop.nce.development'] = settings
     from djangorecipe import test
     test.main('cheeseshop.nce.development',  'tilsit', 'stilton')
     self.assertEqual(execute_manager.call_args[0], (settings,))
Пример #10
0
 def test_deeply_nested_settings(self, execute_manager):
     # Settings files can be more than two levels deep. We need to
     # make sure the test script can properly import those. To
     # demonstrate this we need to add another level to our
     # sys.modules entries.
     settings = mock.sentinel.SettingsModule
     nce = mock.sentinel.NCE
     nce.development = settings
     sys.modules['cheeseshop'].nce = nce
     sys.modules['cheeseshop.nce'] = nce
     sys.modules['cheeseshop.nce.development'] = settings
     from djangorecipe import test
     test.main('cheeseshop.nce.development',  'tilsit', 'stilton')
     self.assertEqual(execute_manager.call_args[0], (settings,))
Пример #11
0
    def test_deeply_nested_settings(self, mock_setdefault, execute_from_command_line):
        # Settings files can be more than two levels deep. We need to
        # make sure the test script can properly import those. To
        # demonstrate this we need to add another level to our
        # sys.modules entries.
        settings = mock.sentinel.SettingsModule
        settings.SECRET_KEY = "I mock your secret key"
        nce = mock.sentinel.NCE
        nce.development = settings
        sys.modules["cheeseshop"].nce = nce
        sys.modules["cheeseshop.nce"] = nce
        sys.modules["cheeseshop.nce.development"] = settings
        from djangorecipe import test

        test.main("cheeseshop.nce.development", "tilsit", "stilton")
        self.assertEqual(mock_setdefault.call_args[0], ("DJANGO_SETTINGS_MODULE", "cheeseshop.nce.development"))
Пример #12
0
 def test_deeply_nested_settings(self, mock_setdefault, execute_from_command_line):
     # Settings files can be more than two levels deep. We need to
     # make sure the test script can properly import those. To
     # demonstrate this we need to add another level to our
     # sys.modules entries.
     settings = mock.sentinel.SettingsModule
     settings.SECRET_KEY = 'I mock your secret key'
     nce = mock.sentinel.NCE
     nce.development = settings
     sys.modules['cheeseshop'].nce = nce
     sys.modules['cheeseshop.nce'] = nce
     sys.modules['cheeseshop.nce.development'] = settings
     from djangorecipe import test
     test.main('cheeseshop.nce.development',  'tilsit', 'stilton')
     self.assertEqual(mock_setdefault.call_args[0],
                      ('DJANGO_SETTINGS_MODULE', 'cheeseshop.nce.development'))
Пример #13
0
 def test_settings_error(self, sys_exit):
     # When the settings file cannot be imported the test runner
     # wil exit with a message and a specific exit code.
     test.main('cheeseshop.tilsit', 'stilton')
     self.assertEqual(sys_exit.call_args, ((1,), {}))