Beispiel #1
0
    def test_gen_check_output(self) -> None:
        loop = asyncio.get_event_loop()
        stdout, stderr = loop.run_until_complete(
            lib._gen_check_output([lib.BLACK_BINARY, "--help"]))
        self.assertTrue(
            "The uncompromising code formatter" in stdout.decode("utf8"))
        self.assertEqual(None, stderr)

        # TODO: Add a test to see failure works on Windows
        if lib.WINDOWS:
            return

        false_bin = "/usr/bin/false" if system() == "Darwin" else "/bin/false"
        with self.assertRaises(CalledProcessError):
            loop.run_until_complete(lib._gen_check_output([false_bin]))

        with self.assertRaises(asyncio.TimeoutError):
            loop.run_until_complete(
                lib._gen_check_output(["/bin/sleep", "2"], timeout=0.1))
Beispiel #2
0
    def test_gen_check_output(self) -> None:
        loop = asyncio.get_event_loop()
        stdout, stderr = loop.run_until_complete(
            lib._gen_check_output([lib.BLACK_BINARY, '--help']))
        self.assertTrue(
            'The uncompromising code formatter' in stdout.decode('utf8'))
        self.assertEqual(None, stderr)

        # TODO: Add a test to see failure works on Windows
        if lib.WINDOWS:
            return

        false_bin = '/usr/bin/false' if system() == 'Darwin' else '/bin/false'
        with self.assertRaises(CalledProcessError):
            loop.run_until_complete(lib._gen_check_output([false_bin]))

        with self.assertRaises(asyncio.TimeoutError):
            loop.run_until_complete(
                lib._gen_check_output(['/bin/sleep', '2'], timeout=0.1))