Skip to content

Bug introduced by declarative PR #1157

@Jammy2211

Description

@Jammy2211

The following PR:

#1153

Broken unit tests:

    def test_without(self, tuple_model):
        with_paths = tuple_model.without_paths([
            ("tup",)
        ])

>       assert not hasattr(with_paths, "tup")
E       AssertionError: assert not True
E        +  where True = hasattr(<Model MockWithTuple >, 'tup')

test_autofit/mapper/with_paths/test_model.py:215: AssertionError

For now I've commented out troublesome code which means all tests pass:

    def __getattr__(self, item):
        try:
            if (
                "_" in item
                and item not in ("_is_frozen", "tuple_prior_tuples")
                and not item.startswith("_")
            ):
                return getattr(
                    [v for k, v in self.tuple_prior_tuples if item.split("_")[0] == k][
                        0
                    ],
                    item,
                )

        except IndexError:
            pass

        self.__getattribute__(item)

    # def __getattr__(self, item):
    #     if item in ("_is_frozen", "tuple_prior_tuples"):
    #         return self.__getattribute__(item)
    #
    #     try:
    #         if "_" in item and not item.startswith("_"):
    #             return getattr(
    #                 [v for k, v in self.tuple_prior_tuples if item.split("_")[0] == k][
    #                     0
    #                 ],
    #                 item,
    #             )
    #
    #     except IndexError:
    #         pass
    #
    #     try:
    #         return getattr(
    #             self.instance_for_arguments(
    #                 {prior: prior for prior in self.priors},
    #             ),
    #             item,
    #         )
    #     except (AttributeError, TypeError):
    #         pass
    #
    #     self.__getattribute__(item)

I therefore also commented out this unit test:

https://github.com/rhayes777/PyAutoFit/blob/main/test_autofit/graphical/test_declarative_deterministic.py

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions