Пример #1
0
    def test_create_fails_if_not_exist(self):
        path = 'good/path'
        sc_path = MagicMock(Path)
        sc_path.__str__.return_value = path
        sc_path.exists.return_value = False

        with self.assertRaises(BinaryNotFoundError) as cm:
            Runner.create(sc_path)

        self.assertEqual(sc_path, cm.exception.filename)
Пример #2
0
    def test_create_fails_if_not_executable(self, os):
        path = 'good/path'
        sc_path = MagicMock(Path)
        sc_path.__str__.return_value = path
        sc_path.exists.return_value = True
        os.access.return_value = False

        with self.assertRaises(BinaryNotExecutableError) as cm:
            Runner.create(sc_path)

        self.assertEqual(sc_path, cm.exception.filename)

        sc_path.exists.assert_called_once_with()
        os.access.assert_called_once_with(path, os.X_OK)
Пример #3
0
    def test_create(self, os):
        path = 'good/path'
        sc_path = MagicMock(Path)
        sc_path.__str__.return_value = path
        sc_path.exists.return_value = True
        os.access.return_value = True

        self.assertEqual(sc_path, Runner.create(sc_path)._sc_path)  # noqa  # pylint: disable=W0212

        sc_path.exists.assert_called_once_with()
        os.access.assert_called_once_with(path, os.X_OK)
Пример #4
0
def _make_runner(path: str) -> Runner:
    try:
        return Runner.create(Path(Path.cwd(), path))
    except BinaryNotFoundError as e:
        cmd = "{} --sc path/to/sc".format(argv[0])
        msg = "simple compiler does not exist: {} (try: {})" \
            .format(e.filename, cmd)

        raise ArgumentTypeError(msg)
    except BinaryNotExecutableError as e:
        cmd = "chmod +x {}".format(e.filename)
        msg = "simple compiler is not executable: {} (try: {})" \
            .format(e.filename, cmd)

        raise ArgumentTypeError(msg)
Пример #5
0
    def setUp(self):
        path = 'path/to/sc'
        self.sc_path = MagicMock(spec=Path)
        self.sc_path.__str__.return_value = path

        self.runner = Runner(self.sc_path)
Пример #6
0
 def setUp(self):
     self.sc_path = Path('path/to/sc')
     self.runner = Runner(self.sc_path)