Exemple #1
0
 def test_migration_failure_message(self, captured_output):
     bad_migration = ['checkmigrations', '--migration-path', MIGRATIONS_DIR]
     with patch('argparse._sys.argv', bad_migration):
         try:
             check_migration_name()
         except (SystemExit):
             message = 'must be renamed to something more descriptive'
             self.assertIn(message, captured_output.getvalue())
         else:
             self.fail('SystemExit not raised')
Exemple #2
0
 def test_qa_call_check_migration_name_pass(self):
     options = [
         'checkmigrations', '--migrations-to-ignore', '2',
         '--migration-path', MIGRATIONS_DIR, '--quiet'
     ]
     with patch('argparse._sys.argv', options):
         try:
             check_migration_name()
         except (SystemExit, Exception) as e:
             self.fail(e)
 def test_migration_failure_message(self):
     bad_migration = ['checkmigrations', '--migration-path', MIGRATIONS_DIR]
     with patch('argparse._sys.argv', bad_migration):
         captured_output = io.StringIO()
         sys.stdout = captured_output  # redirect stdout
         try:
             check_migration_name()
         except (SystemExit):
             message = 'must be renamed to something more descriptive'
             self.assertIn(message, captured_output.getvalue())
         else:
             self.fail('SystemExit not raised')
         finally:
             sys.stdout = sys.__stdout__  # reset redirect
Exemple #4
0
 def test_qa_call_check_migration_name_failure(self):
     options = [[
         'checkmigrations', '--migrations-to-ignore', '1',
         '--migration-path', MIGRATIONS_DIR, '--quiet'
     ], ['checkmigrations', '--migration-path', MIGRATIONS_DIR, '--quiet'],
                ['checkmigrations']]
     for option in options:
         with patch('argparse._sys.argv', option):
             try:
                 check_migration_name()
             except (SystemExit):
                 pass
             else:
                 self.fail('SystemExit not raised')
Exemple #5
0
 def test_qa_call_check_migration_name_failure(self):
     options = [
         [
             'checkmigrations',
             '--migrations-to-ignore',
             '1',
             '--migration-path',
             MIGRATIONS_DIR,
             '--quiet',
         ],
         ['checkmigrations', '--migration-path', MIGRATIONS_DIR, '--quiet'],
         ['checkmigrations'],
     ]
     for option in options:
         with patch('argparse._sys.argv', option), self.subTest(option):
             with self.assertRaises(SystemExit):
                 check_migration_name()