'Creates and builds a fake Sphinx project as if via the command line,
failing if there are any warnings.'

def test_warningsAreErrors(self):

    output = StringIO()
    self.patch(sys, 'stdout', output)
    self.createFakeSphinxProject()
    with self.sphinxDir.child('index.rst').open('a') as f:
        f.write('\n..    _malformed-link-target\n')
    exception = self.assertRaises(SystemExit, self.builder.main, [self.sphinxDir.parent().path])
    self.assertEqual(exception.code, 1)
    self.assertIn('malformed    hyperlink    target', output.getvalue())
    self.verifyBuilt()
