Files
cleveragents-core/features/test_utils_coverage.feature
T
2025-11-11 20:09:06 -05:00

246 lines
5.6 KiB
Gherkin

Feature: Test Utils Coverage
As a developer
I want to ensure the test utilities are thoroughly tested
So that the Robot Framework indentation fixing utility works correctly
@unit
Scenario: Fix simple Python function indentation
Given I import the fix_python_indentation function
When I provide a simple function without indentation:
"""
def hello():
print("Hello")
return True
"""
Then the output should have proper indentation:
"""
def hello():
print("Hello")
return True
"""
@unit
Scenario: Handle empty lines in Python code
Given I import the fix_python_indentation function
When I provide code with empty lines:
"""
def test():
pass
"""
Then the output should preserve empty lines:
"""
def test():
pass
"""
@unit
Scenario: Fix if-else statement indentation
Given I import the fix_python_indentation function
When I provide an if-else block without indentation:
"""
if condition:
do_something()
else:
do_something_else()
"""
Then the output should have proper if-else indentation:
"""
if condition:
do_something()
else:
do_something_else()
"""
@unit
Scenario: Fix if-elif-else statement indentation
Given I import the fix_python_indentation function
When I provide an if-elif-else block without indentation:
"""
if x > 0:
positive()
elif x < 0:
negative()
else:
zero()
"""
Then the output should have proper if-elif-else indentation:
"""
if x > 0:
positive()
elif x < 0:
negative()
else:
zero()
"""
@unit
Scenario: Fix try-except block indentation
Given I import the fix_python_indentation function
When I provide a try-except block without indentation:
"""
try:
risky_operation()
except ValueError:
handle_value_error()
except Exception:
handle_general_error()
"""
Then the output should have proper try-except indentation:
"""
try:
risky_operation()
except ValueError:
handle_value_error()
except Exception:
handle_general_error()
"""
@unit
Scenario: Fix try-except-finally block indentation
Given I import the fix_python_indentation function
When I provide a try-except-finally block without indentation:
"""
try:
risky_operation()
except:
handle_error()
finally:
cleanup()
"""
Then the output should have proper try-except-finally indentation:
"""
try:
risky_operation()
except:
handle_error()
finally:
cleanup()
"""
@unit
Scenario: Fix nested blocks indentation
Given I import the fix_python_indentation function
When I provide nested blocks without indentation:
"""
class MyClass:
def method(self):
if self.condition:
try:
self.do_something()
except:
pass
else:
self.do_other()
"""
Then the output should have proper nested indentation:
"""
class MyClass:
def method(self):
if self.condition:
try:
self.do_something()
except:
pass
else:
self.do_other()
"""
@unit
Scenario: Handle code with only empty lines
Given I import the fix_python_indentation function
When I provide code with only empty lines:
"""
"""
Then the output should preserve empty lines:
"""
"""
@unit
Scenario: Fix while loop indentation
Given I import the fix_python_indentation function
When I provide a while loop without indentation:
"""
while condition:
do_something()
counter += 1
"""
Then the output should have proper while loop indentation:
"""
while condition:
do_something()
counter += 1
"""
@unit
Scenario: Fix for loop indentation
Given I import the fix_python_indentation function
When I provide a for loop without indentation:
"""
for item in items:
process(item)
print(item)
"""
Then the output should have proper for loop indentation:
"""
for item in items:
process(item)
print(item)
"""
@unit
Scenario: Handle single line without colon
Given I import the fix_python_indentation function
When I provide a single line without colon:
"""
print("Hello World")
"""
Then the output should have no indentation:
"""
print("Hello World")
"""
@unit
Scenario: Fix with statement indentation
Given I import the fix_python_indentation function
When I provide a with statement without indentation:
"""
with open('file.txt') as f:
content = f.read()
print(content)
"""
Then the output should have proper with statement indentation:
"""
with open('file.txt') as f:
content = f.read()
print(content)
"""
@unit
Scenario: Handle mixed empty and non-empty lines
Given I import the fix_python_indentation function
When I provide code with mixed empty and non-empty lines:
"""
def function():
first_statement()
second_statement()
"""
Then the output should handle mixed lines correctly:
"""
def function():
first_statement()
second_statement()
"""