Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testdata overriding methods #166

Closed
Jaymon opened this issue Jun 24, 2023 · 0 comments
Closed

Testdata overriding methods #166

Jaymon opened this issue Jun 24, 2023 · 0 comments

Comments

@Jaymon
Copy link
Owner

Jaymon commented Jun 24, 2023

This does not work:

class ModelData(prom.extras.testdata.ModelData):
    def get_<MODEL_NAME>_fields(self, **kwargs):
        instance = self.get_<OTHER_MODEL_NAME>(**kwargs)

because calling self.get_<OTHER_MODEL_NAME> passes in the orm_class and overrides the magic get_<OTHER_MODEL_NAME> resolver.

I was able to get it to work doing this:

class ModelData(prom.extras.testdata.ModelData):
    def get_<MODEL_NAME>_fields(self, **kwargs):
        orm_class = kwargs.pop("orm_class")
        instance = self.get_<OTHER_MODEL_NAME>(**kwargs)

But I'd love to get it to work automatically somehow, no idea how to do it yet though, or even if it is possible.

@Jaymon Jaymon closed this as completed in faa35f7 Jun 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant