How to use the vermin.main function in vermin

To help you get started, we’ve selected a few vermin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netromdk / vermin / tests / general.py View on Github external
def test_main_no_rules_hit(self):
    # Python file that doesn't hit any rules should exit successfully.
    fp = NamedTemporaryFile(suffix=".py", delete=False)
    fp.close()
    with self.assertRaises(SystemExit) as ex:
      sys.argv = [sys.argv[0], fp.name]
      main()
    os.remove(fp.name)
    sys.argv = [sys.argv[0]]
    self.assertEqual(ex.exception.code, 0)
github netromdk / vermin / tests / general.py View on Github external
def test_main_no_args(self):
    # Print usage and exit with code 1.
    with self.assertRaises(SystemExit) as ex:
      main()
    self.assertEqual(ex.exception.code, 1)
github netromdk / vermin / tests / general.py View on Github external
def test_main_target_not_met(self):
    # Ensure exit code 1 when target isn't met.
    fp = NamedTemporaryFile(suffix=".py", delete=False)
    fp.close()
    with self.assertRaises(SystemExit) as ex:
      sys.argv = [sys.argv[0], "-t=3.0", fp.name]
      main()
    os.remove(fp.name)
    sys.argv = [sys.argv[0]]
    self.assertEqual(ex.exception.code, 1)
github netromdk / vermin / tests / general.py View on Github external
def test_main_no_paths(self):
    # The path doesn't exist and isn't a .py file which means no paths are detected.
    with self.assertRaises(SystemExit) as ex:
      sys.argv = [sys.argv[0], "nonexistentfilethatisntpy"]
      main()
    sys.argv = [sys.argv[0]]
    self.assertEqual(ex.exception.code, 1)