mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	ruff: Fix SIM115 Use context handler for opening files.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							c6b6004432
						
					
				
				
					commit
					6303ebfc2f
				
			@@ -41,7 +41,8 @@ def test_generated_curl_examples_for_success(client: Client) -> None:
 | 
			
		||||
    rest_endpoints_path = os.path.join(
 | 
			
		||||
        settings.DEPLOY_ROOT, "templates/zerver/api/include/rest-endpoints.md"
 | 
			
		||||
    )
 | 
			
		||||
    rest_endpoints_raw = open(rest_endpoints_path).read()
 | 
			
		||||
    with open(rest_endpoints_path) as f:
 | 
			
		||||
        rest_endpoints_raw = f.read()
 | 
			
		||||
    ENDPOINT_REGEXP = re.compile(r"/api/\s*(.*?)\)")
 | 
			
		||||
    endpoint_list = sorted(set(re.findall(ENDPOINT_REGEXP, rest_endpoints_raw)))
 | 
			
		||||
 | 
			
		||||
@@ -51,12 +52,12 @@ def test_generated_curl_examples_for_success(client: Client) -> None:
 | 
			
		||||
        curl_commands_to_test = []
 | 
			
		||||
 | 
			
		||||
        if os.path.exists(file_name):
 | 
			
		||||
            f = open(file_name)
 | 
			
		||||
            for line in f:
 | 
			
		||||
                # A typical example from the Markdown source looks like this:
 | 
			
		||||
                #     {generate_code_example(curl)|...|...}
 | 
			
		||||
                if line.startswith("{generate_code_example(curl"):
 | 
			
		||||
                    curl_commands_to_test.append(line)
 | 
			
		||||
            with open(file_name) as f:
 | 
			
		||||
                for line in f:
 | 
			
		||||
                    # A typical example from the Markdown source looks like this:
 | 
			
		||||
                    #     {generate_code_example(curl)|...|...}
 | 
			
		||||
                    if line.startswith("{generate_code_example(curl"):
 | 
			
		||||
                        curl_commands_to_test.append(line)
 | 
			
		||||
        else:
 | 
			
		||||
            # If the file doesn't exist, then it has been
 | 
			
		||||
            # deleted and its page is generated by the
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user