Ejemplo n.º 1
0
    def test_empty_variable_kwargs_functionality(self):
        simple_object_1 = SimpleSerializable(
            'ARG1', *('ARGS[1]', 'ARGS[2]'), kwarg1='KWARG1')

        simple_object_2 = Serializable.clone(simple_object_1)

        assert_objects_match(simple_object_1, simple_object_2)
Ejemplo n.º 2
0
    def copy(self):
        """Create a deep copy the environment.

        TODO: Investigate if this can be done somehow else, especially for gym
        envs.
        """
        return Serializable.clone(self)
Ejemplo n.º 3
0
    def test_variable_kwargs_functionality(self):
        simple_object_1 = SimpleSerializable(
            'ARG1', **{'kwargs[1]': 'KWARGS[1]',
                       'kwargs[2]': 'KWARGS[2]'})

        simple_object_2 = Serializable.clone(simple_object_1)

        assert_objects_match(simple_object_1, simple_object_2)
Ejemplo n.º 4
0
    def test_default_initialization(self):
        class UninitializedSerializable(Serializable):

            def __init__(self, arg1, *args, kwarg1=None, **kwargs):
                self.arg1 = arg1
                self.args = args
                self.kwarg1 = kwarg1
                self.kwargs = kwargs

        simple_object_1 = UninitializedSerializable(
            'ARG1',
            *('ARGS[1]', 'ARGS[2]'),
            kwarg1='KWARG1',
            **{'kwargs[1]': 'KWARGS[1]',
               'kwargs[2]': 'KWARGS[2]'})

        with self.assertRaises(AssertionError):
            Serializable.clone(simple_object_1)
Ejemplo n.º 5
0
    def test_missing_default_values(self):
        simple_object_1 = SimpleSerializable(
            'ARG1', *('ARGS[1]', 'ARGS[2]'),
            **{'kwargs[1]': 'KWARGS[1]',
               'kwargs[2]': 'KWARGS[2]'})

        simple_object_2 = Serializable.clone(simple_object_1)

        assert_objects_match(simple_object_1, simple_object_2)
Ejemplo n.º 6
0
    def test_mixed_argument_types(self):
        simple_object_1 = SimpleSerializable(
            'ARG1',
            *('ARGS[1]', 'ARGS[2]'),
            kwarg1='KWARG1',
            **{'kwargs[1]': 'KWARGS[1]',
               'kwargs[2]': 'KWARGS[2]'})

        simple_object_2 = Serializable.clone(simple_object_1)

        assert_objects_match(simple_object_1, simple_object_2)
Ejemplo n.º 7
0
    def test_kwargs_functionality(self):
        simple_object_1 = SimpleSerializable('ARG1', kwarg1='KWARG1')
        simple_object_2 = Serializable.clone(simple_object_1)

        assert_objects_match(simple_object_1, simple_object_2)