Subscribe Join 180,000+ subscribers and receive articles from our blog about software quality, testing, QA and security. Subscribe

Python API comment linebreaks

I am submitting results to Testrail via the API using the Python binding. When using the client.send_post command, is it possible to add line breaks to text strings? For example when submitting a comment, the command would be:

client.send_post(
‘add_result_for_case/1001/1001’,
{
‘status_id’: 1,
‘comment’: ‘This 1 line of a comment. This is the second line of a comment,’
}
)

I would like this to appear in the comment section on testrail as:

This is 1 line of a comment.
This is the second line of a comment

Currently it appears as:

This is 1 line of a comment. This is the second line of a comment.

I would also like to do this for ‘actual’, but I assume it would be the same.

How do I acheive this?
Thanks!

In C# I use Environment.NewLine. I guess in python it can be \r\n, \r or \n.

3 Likes

Thanks. I was being foolish and putting my slashes the wrong way. All the solutions work.
Thanks again!