Search code examples
pythonyamlpyyamlblack-box-testing

yaml.scanner.ScannerError: mapping values are not allowed in this context (Python Black Box Testing help)


I am trying to run use PBBT to call in input of a .yaml file which will then run the .py file. But I keep getting the following error "yaml.constructor.ConstructorError: expected a sequence of test records in "input12sys.yaml",line 3 column 3" (edit). I will attach the actual python bit for both the input file and the .yaml. So everyone can see what I might be/am doing wrong.

Any help getting this working properly would be greatly apprecaited as I am a novice at this whole pbbt thing. Here is the .py file we want to have ran with the .yaml for pbbt (Daniel_Rogers_HW2.py is the file name)

import sys
# create a list
list2 = [4, 5, 1, 3, 7, 2, 5]
SumList = sum(list2)
print ("Dear Daniel")
print (*list2 , sep = " + ", end ='')
print (" =" , SumList)

Here is the .yaml file (edited)

output: output12sys.yaml
tests:
   py: Daniel_Rogers_HW2.py
   except: ValueError

And here is the error that I am getting when running pbbt input12sys.yaml -T enter image description here


Solution

  • Your YAML file starts with:

    import yaml
    
    output:
    

    And you cannot have a non-quoted multi-line scalar (import yaml\n\noutput) as a key for mapping. You probably just want to delete the import yaml line and if not you need to apply quotes:

    "import yaml
    
    output": output12sys.yaml
    

    Assuming that import yaml is erroneous, you probably want to review your pbbt documentation, as the value for tests should be a list judging from https://bitbucket.org/prometheus/pbbt/src/default/. I.e. look like

    output: output12sys.yaml
    tests:
    -  py: Daniel_Rogers_HW2.py    # note the list item indicator at the start of the line
       except: ValueError