Esempio n. 1
0
 def test_prints_version_when_requested_and_exits(self):
     with self.assertRaises(SystemExit) as cm:
         parse_args(['fileinfo.py', '--version'])
     self.assertEqual(cm.exception.code, 0)
     # Python < 3.4 emits the version to stderr, Python >= 3.4 to stdout.
     output = self.stdout.getvalue() + self.stderr.getvalue()
     self.assertIn(__version__, output)
Esempio n. 2
0
 def test_verbose_is_parsed_correctly_long_form(self):
     args = parse_args(['fileinfo.py', '--verbose', 'prog.exe'])
     self.assertTrue(args.verbose)
Esempio n. 3
0
 def test_api_url_is_parsed_correctly_long_form(self):
     args = parse_args(['fileinfo.py', '--api-url', 'URL', 'prog.exe'])
     self.assertEqual(args.api_url, 'URL')
Esempio n. 4
0
 def test_api_key_is_parsed_correctly_long_form(self):
     args = parse_args(['fileinfo.py', '--api-key', 'KEY', 'prog.exe'])
     self.assertEqual(args.api_key, 'KEY')
Esempio n. 5
0
 def test_file_is_parsed_correctly(self):
     args = parse_args(['fileinfo.py', 'prog.exe'])
     self.assertEqual(args.input_file, 'prog.exe')
Esempio n. 6
0
 def test_file_is_required(self):
     with self.assertRaises(SystemExit) as cm:
         parse_args(['fileinfo.py'])
     self.assertNotEqual(cm.exception.code, 0)
Esempio n. 7
0
 def test_verbose_is_parsed_correctly_long_form(self):
     args = parse_args(['fileinfo.py', '--verbose', 'prog.exe'])
     self.assertTrue(args.verbose)
Esempio n. 8
0
 def test_api_url_is_parsed_correctly_long_form(self):
     args = parse_args(['fileinfo.py', '--api-url', 'URL', 'prog.exe'])
     self.assertEqual(args.api_url, 'URL')
Esempio n. 9
0
 def test_api_key_is_parsed_correctly_long_form(self):
     args = parse_args(['fileinfo.py', '--api-key', 'KEY', 'prog.exe'])
     self.assertEqual(args.api_key, 'KEY')
Esempio n. 10
0
 def test_file_is_parsed_correctly(self):
     args = parse_args(['fileinfo.py', 'prog.exe'])
     self.assertEqual(args.input_file, 'prog.exe')
Esempio n. 11
0
 def test_file_is_required(self):
     with self.assertRaises(SystemExit) as cm:
         parse_args(['fileinfo.py'])
     self.assertNotEqual(cm.exception.code, 0)
Esempio n. 12
0
    def test_output_format_is_parsed_correctly_long_form(self):
        args = parse_args(
            ['fileinfo.py', '--output-format', 'json', 'prog.exe'])

        self.assertEqual(args.output_format, 'json')
Esempio n. 13
0
    def test_api_url_is_none_when_not_given(self):
        # This is important because it enables the use of the RETDEC_API_URL
        # environment variable.
        args = parse_args(['fileinfo.py', 'prog.exe'])

        self.assertIsNone(args.api_url)
Esempio n. 14
0
    def test_api_key_is_none_when_not_given(self):
        # This is important because it enables the use of the RETDEC_API_KEY
        # environment variable.
        args = parse_args(['decompiler.py', 'prog.exe'])

        self.assertIsNone(args.api_key)