def test_no_source(self):
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('')
     self.assertEqual(context.exception.code, 0)
     self.assertLogs(
         debug=["'versions' section not found in versions.cfg."],
         info=['- 0 packages need to be checked for updates.'])
     self.assertStdOut('')
Exemple #2
0
 def test_no_source(self):
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('')
     self.assertEqual(context.exception.code, 0)
     self.assertLogs(
         debug=["'versions' section not found in versions.cfg."],
         info=['- 0 packages need to be checked for updates.'])
     self.assertStdOut('')
Exemple #3
0
 def test_handle_error(self):
     original_listdir_content = self.listdir_content
     self.listdir_content = 42
     config_file = NamedTemporaryFile()
     config_file.write('[versions]\n'.encode('utf-8'))
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('%s' % config_file.name)
     self.assertEqual(context.exception.code,
                      "'int' object is not iterable")
     self.listdir_content = original_listdir_content
 def test_handle_error(self):
     original_listdir_content = self.listdir_content
     self.listdir_content = 42
     config_file = NamedTemporaryFile()
     config_file.write('[versions]\n'.encode('utf-8'))
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('%s' % config_file.name)
     self.assertEqual(context.exception.code,
                      "'int' object is not iterable")
     self.listdir_content = original_listdir_content
Exemple #5
0
 def test_output_none(self):
     config_file = NamedTemporaryFile()
     config_file.write('[versions]\nEgg=1.0\n'
                       'Unused-egg=1.0\n'.encode('utf-8'))
     config_file.seek(0)
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('%s -q' % config_file.name)
     self.assertEqual(context.exception.code, 0)
     self.assertStdOut('')
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('invalid -qqqq')
     self.assertEqual(context.exception.code, 0)
     self.assertStdOut('')
     config_file.close()
Exemple #6
0
 def test_exclude(self):
     config_file = NamedTemporaryFile()
     config_file.write('[versions]\nEgg=1.0\n'
                       'Unused-egg=1.0\n'.encode('utf-8'))
     config_file.seek(0)
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('%s -e unused-egg' % config_file.name)
     self.assertEqual(context.exception.code, 0)
     self.assertLogs(info=[
         '- 2 versions found in %s.' %
         config_file.name, '- 1 packages need to be checked for updates.'
     ])
     self.assertStdOut('')
     config_file.close()
 def test_output_none(self):
     config_file = NamedTemporaryFile()
     config_file.write('[versions]\nEgg=1.0\n'
                       'Unused-egg=1.0\n'.encode('utf-8'))
     config_file.seek(0)
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('%s -q' % config_file.name)
     self.assertEqual(context.exception.code, 0)
     self.assertStdOut('')
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('invalid -qqqq')
     self.assertEqual(context.exception.code, 0)
     self.assertStdOut('')
     config_file.close()
 def test_exclude(self):
     config_file = NamedTemporaryFile()
     config_file.write('[versions]\nEgg=1.0\n'
                       'Unused-egg=1.0\n'.encode('utf-8'))
     config_file.seek(0)
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('%s -e unused-egg' %
                                      config_file.name)
     self.assertEqual(context.exception.code, 0)
     self.assertLogs(
         info=['- 2 versions found in %s.' % config_file.name,
               '- 1 packages need to be checked for updates.'])
     self.assertStdOut('')
     config_file.close()
 def test_write(self):
     config_file = NamedTemporaryFile()
     config_file.write('[versions]\nEgg=1.0\n'
                       'Unused-egg=1.0\n'.encode('utf-8'))
     config_file.seek(0)
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('%s -w' % config_file.name)
     self.assertEqual(context.exception.code, 0)
     self.assertLogs(
         info=['- 2 versions found in %s.' % config_file.name,
               '- 2 packages need to be checked for updates.',
               '- %s updated.' % config_file.name],
         warning=['- Unused-egg is unused.'])
     self.assertStdOut('- Unused-egg is unused.\n')
     self.assertEquals(
         config_file.read().decode('utf-8'),
         '[versions]\nEgg                             = 1.0\n')
Exemple #10
0
 def test_write(self):
     config_file = NamedTemporaryFile()
     config_file.write('[versions]\nEgg=1.0\n'
                       'Unused-egg=1.0\n'.encode('utf-8'))
     config_file.seek(0)
     with self.assertRaises(SystemExit) as context:
         find_unused_versions.cmdline('%s -w' % config_file.name)
     self.assertEqual(context.exception.code, 0)
     self.assertLogs(info=[
         '- 2 versions found in %s.' % config_file.name,
         '- 2 packages need to be checked for updates.',
         '- %s updated.' % config_file.name
     ],
                     warning=['- Unused-egg is unused.'])
     self.assertStdOut('- Unused-egg is unused.\n')
     self.assertEquals(
         config_file.read().decode('utf-8'),
         '[versions]\nEgg                             = 1.0\n')