Beispiel #1
0
    def __init__(self, env_name: str, tmp_dir: Any = None) -> None:
        """
        Creates a new virtual environment in a temporary folder.

        :param env_name: Name of the virtual environment
        :param tmp_dir: Directory where the temporary folder should be created
        """
        Preconditions.check_argument(
            len(env_name) > 0,
            "Cannot create an virtual environment without a name!",
        )
        self._env_name = env_name
        self._packages: List[str] = []

        self._env_dir = tempfile.mkdtemp(suffix=env_name, dir=tmp_dir)
        virtualenv.create_environment(self._env_dir)
Beispiel #2
0
 def test_check_argument_false_no_msg(self):
     with self.assertRaises(IllegalArgumentException) as context:
         Preconditions.check_argument(False)
     self.assertTrue(isinstance(context.exception,
                                IllegalArgumentException))
Beispiel #3
0
 def test_check_argument_false_msg(self):
     m = "message"
     with self.assertRaises(IllegalArgumentException) as context:
         Preconditions.check_argument(False, m)
     self.assertTrue(m in str(context.exception))
Beispiel #4
0
 def test_check_argument_true_msg(self):
     try:
         Preconditions.check_argument(True, "message")
     except IllegalArgumentException:  # pragma: no cover
         self.fail("check_argument() raised IllegalArgumentException "
                   "unexpectedly!")  # pragma: no cover