def test_RunWithErrorHandling_exception_debug(clgen_cache_dir): """Test that FLAGS.debug disables exception catching.""" del clgen_cache_dir FLAGS.unparse_flags() FLAGS(["argv0"]) FLAGS.clgen_debug = True with test.Raises(ZeroDivisionError): clgen.RunWithErrorHandling(lambda a, b: a // b, 1, 0)
def test_RunWithErrorHandling_return_value(clgen_cache_dir): """Test that RunWithErrorHandling() returns correct value for function.""" del clgen_cache_dir assert clgen.RunWithErrorHandling(lambda a, b: a // b, 4, 2) == 2
def test_RunWithErrorHandling_system_exit(clgen_cache_dir): """Test that SystemExit is raised on exception.""" del clgen_cache_dir with test.Raises(SystemExit): clgen.RunWithErrorHandling(lambda a, b: a // b, 1, 0)
def test_RunWithErrorHandling_exception_debug(clgen_cache_dir): """Test that FLAGS.debug disables exception catching.""" del clgen_cache_dir app.FLAGS(['argv[0]', '--clgen_debug']) with pytest.raises(ZeroDivisionError): clgen.RunWithErrorHandling(lambda a, b: a // b, 1, 0)