I recently upgraded to python 3.12 and noticed my aloe test cases are no longer working. Specifically the Examples table at the end of the feature file. If I insert the same table after specific steps and omit the "Examples" header, it works. I am curious if anyone else is experiencing the same issue and has found a solution.
The specific error I am seeing is: ERROR: Failure: ValueError (AST node line range (7, 3) is not valid). I have not touched any of the site package code.
======================================================================
ERROR: Failure: ValueError (AST node line range (7, 3) is not valid)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/bhuang/aloe_testing/lib/python3.12/site-packages/nose/failure.py", line 35, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/home/bhuang/aloe_testing/lib/python3.12/site-packages/nose/plugins/manager.py", line 124, in generate
for r in result:
File "/home/bhuang/aloe_testing/lib/python3.12/site-packages/aloe/plugin.py", line 190, in loadTestsFromFile
test = self.test_class.from_file(file_)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bhuang/aloe_testing/lib/python3.12/site-packages/aloe/testclass.py", line 175, in from_file
for example in cls.make_examples(scenario, i + 1):
File "/home/bhuang/aloe_testing/lib/python3.12/site-packages/aloe/testclass.py", line 265, in make_examples
make_function(
File "/home/bhuang/aloe_testing/lib/python3.12/site-packages/aloe/codegen.py", line 42, in make_function
code = compile(func, source_file, 'exec')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: AST node line range (7, 3) is not valid
----------------------------------------------------------------------
Ran 1 test in 0.001s
FAILED (errors=1)
When looking into the error, it looks like it originates from the first entry in Examples table. In my case, its the first sample name e.g., S123.
Below is an example of my feature and step file, however these are a simplified version. I have many more columns in the Examples table than shown.
Feature file:
Feature: Test a step using some form of automation
Scenario Outline: Given a sample, it will start and complete the step.
Given I have a sample <s_name>
Examples:
|s_name|
|S123 |
Step file:
@step('Given I have a sample (\w+)')
def test_add_sample(step, s_name):
print(s_name) # The code exits before this print statement and is likely occurring when the examples are being compiled.
Thanks in advance!
I have tried running the code in a virtual environment and without. I have inserted the same Examples table (without the header) after a step and that worked. I simplified the Examples table to one column and one entry to see if that would help and it hasn't. I'm not sure what else to try to get the Examples table at the end of the feature file to work. I would like to find out if something has changed in the Examples table formatting and what I can do to get it working again.