Append object to end of list
Question: Im using python with junit_xml to parse a logfile to produce a xml output. My
logfile looks like this:

    
    
    /path/to/app1,app1,success,my@email.com,app1_log.log
    /path/to/app2,app2,fail,my@email.com,app1_log.log
    

I am able to do append multiple TestCase objects to test_cases with the
following code:

    
    
    test_cases = [TestCase('app1), TestCase('app2')]
    

What i need is to go through the logfile line by line and add testresult[0] to
the testcases object.  

    
    
    from junit_xml import TestSuite, TestCase
    
    test_cases=[]
    
    lines = open('testresults.log').readlines()
    
    for line in lines:
        testresult = string.split(string.strip(line), ',')
        test_cases.append(TestCase(testresult[0])
    ts = TestSuite("my test suite", test_cases)
    

The lineparsing part works fine, but i cant seem to add multiple TestCase
objects to the test_case list.


Answer: Changing your code to the following, seems to work:

    
    
    from junit_xml import TestSuite, TestCase
    
    test_cases=[]
    
    lines = open('testresults.log').readlines()
    
    for line in lines:
        testresult = line.split(",")
        test_cases.append(testresult[0])
    
    print test_cases
    

`$ python script.py ['/path/to/app1', '/path/to/app2']`

