'Runs xxd on some random text, and compares output with our xxd.
It\'s conceivable that this isn\'t portable: xxd may have different
default options.
To be honest, this test was written after this was working.
I tested using a temporary file and a side-by-side diff tool (vimdiff).'

def test_compare_to_xxd(self):

    random_text = ''.join((chr(random.getrandbits(8)) for _ in range(LENGTH)))
    p = Popen(['xxd'], shell=True, stdin=PIPE, stdout=PIPE, close_fds=True)
    (stdin, stderr) = p.communicate(random_text)
    self.assertFalse(stderr)
    output = StringIO.StringIO()
    xxd.main(StringIO.StringIO(random_text), output)
    self._verify_content(stdin, output.getvalue())
