Проще:
```python
if self.stacktrace:
    test_result_string += " Stacktrace:\n {}".format(self.stacktrace)
```