@tdd_issue @tdd_issue_2845 @tdd_issue_4178
Feature: TDD Issue #2845 — fix_python_indentation handles try...except...finally correctly
  As a Robot Framework user
  I want fix_python_indentation to correctly reconstruct indentation for try...except...finally blocks
  So that inline Python scripts with exception handling produce syntactically valid code

  Background:
    Given the fix_python_indentation function is available

  @tdd_issue @tdd_issue_4282
  Scenario: Single except clause produces valid Python
    When I fix indentation for a try block with a single except clause
    Then the indentation result should be syntactically valid Python
    And the try body should be indented one level
    And the except clause should be at the same level as try
    And the except body should be indented one level

  @tdd_issue @tdd_issue_4282
  Scenario: Multiple except clauses produce valid Python
    When I fix indentation for a try block with multiple except clauses
    Then the indentation result should be syntactically valid Python
    And all except clauses should be at the same level as try
    And each except body should be indented one level

  @tdd_issue @tdd_issue_4282
  Scenario: try...except...finally produces valid Python
    When I fix indentation for a try block with except and finally
    Then the indentation result should be syntactically valid Python
    And the finally clause should be at the same level as try
    And the finally body should be indented one level

  @tdd_issue @tdd_issue_4282
  Scenario: Nested try blocks produce valid Python
    When I fix indentation for nested try blocks
    Then the indentation result should be syntactically valid Python
    And the inner try should be indented one level inside the outer try
    And the outer except should be at the same level as the outer try

  @tdd_issue @tdd_issue_4282
  Scenario: Nested try with finally then outer except produces valid Python
    When I fix indentation for nested try with inner finally and outer except
    Then the indentation result should be syntactically valid Python
    And the outer except should be at the same level as the outer try

  @tdd_issue @tdd_issue_4282
  Scenario: Code after try block produces valid Python
    When I fix indentation for code that follows a try block
    Then the indentation result should be syntactically valid Python
