def assertTest(self, test_name, pixel_tests, expected_checksum=None, drt_output=None, host=None, expected_text=None): port_name = 'test' host = host or MockSystemHost() test.add_unit_tests_to_mock_filesystem(host.filesystem) port = PortFactory(host).get(port_name) drt_input, drt_output = self.make_input_output( port, test_name, pixel_tests, expected_checksum, drt_output, drt_input=None, expected_text=expected_text) args = ['--platform', port_name] + self.extra_args(pixel_tests) stdin = newstringio.StringIO(drt_input) stdout = newstringio.StringIO() stderr = newstringio.StringIO() options, args = mock_drt.parse_options(args) drt = self.make_drt(options, args, host, stdin, stdout, stderr) res = drt.run() self.assertEqual(res, 0) # We use the StringIO.buflist here instead of getvalue() because # the StringIO might be a mix of unicode/ascii and 8-bit strings. self.assertEqual(stdout.buflist, drt_output) self.assertEqual(stderr.getvalue(), '#EOF\n')
def assertTest(self, test_name, pixel_tests, expected_checksum=None, drt_output=None, filesystem=None): platform = 'test' filesystem = filesystem or test.unit_test_filesystem() port = factory.get(platform, filesystem=filesystem) drt_input, drt_output = self.make_input_output(port, test_name, pixel_tests, expected_checksum, drt_output) args = ['--platform', 'test'] + self.extra_args(pixel_tests) stdin = newstringio.StringIO(drt_input) stdout = newstringio.StringIO() stderr = newstringio.StringIO() options, args = mock_drt.parse_options(args) drt = self.make_drt(options, args, filesystem, stdin, stdout, stderr) res = drt.run() self.assertEqual(res, 0) # We use the StringIO.buflist here instead of getvalue() because # the StringIO might be a mix of unicode/ascii and 8-bit strings. self.assertEqual(stdout.buflist, drt_output) self.assertEqual(stderr.getvalue(), '')
def test_main(self): filesystem = test.unit_test_filesystem() stdin = newstringio.StringIO() stdout = newstringio.StringIO() stderr = newstringio.StringIO() res = mock_drt.main(['--platform', 'test'] + self.extra_args(False), filesystem, stdin, stdout, stderr) self.assertEqual(res, 0) self.assertEqual(stdout.getvalue(), '') self.assertEqual(stderr.getvalue(), '') self.assertEqual(filesystem.written_files, {})
def test_main(self): host = MockSystemHost() test.add_unit_tests_to_mock_filesystem(host.filesystem) stdin = newstringio.StringIO() stdout = newstringio.StringIO() stderr = newstringio.StringIO() res = mock_drt.main(['--platform', 'test'] + self.extra_args(False), host, stdin, stdout, stderr) self.assertEqual(res, 0) self.assertEqual(stdout.getvalue(), '') self.assertEqual(stderr.getvalue(), '') self.assertEqual(host.filesystem.written_files, {})