key_file is a StringIO object, but it needs to be a string containing the name of a file that gpg should be reading from. Alternatively, you can pass the string in through stdin - which is recommended, as it's slightly safer. So:
```python
retvals = self.run(["--import"], output=key_file.read())
```
... might be the right direction.