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

set_trace doesn't stop in the right place #282

Open
novalic opened this issue Aug 6, 2024 · 0 comments
Open

set_trace doesn't stop in the right place #282

novalic opened this issue Aug 6, 2024 · 0 comments

Comments

@novalic
Copy link

novalic commented Aug 6, 2024

Having an issue in several different scenarios. I will describe one here.

I'm running some tests with pytest, and in this case I'm using a pydantic function, the code is:

    def test_something(self, expected_response):
        self.some_mock.return_value = httpx.Response(200, json=expected_response)

        result = some_function({}, {})
        
        assert result.model_dump() == expected_response
        import ipdb; ipdb.set_trace()

this test belongs to a test class, there is a mock definition, and expected_response is a pytest fixture that returns a dictionary.

when i run this, i come here:

    321             else:
    322                 copied.__dict__.update(update)
    323             copied.__pydantic_fields_set__.update(update.keys())
    324         return copied
    325
--> 326     def model_dump(
    327         self,
    328         *,
    329         mode: Literal['json', 'python'] | str = 'python',
    330         include: IncEx = None,

ipdb>

but if i comment the line assert result.model_dump() == expected_reponse things work fine:

     19
     20     def test_something(self, expected_response):
     21         self.some_mock.return_value = httpx.Response(200, json=expected_response)
     22
     23         result = some_function({}, {})
---> 24         import ipdb; ipdb.set_trace()
     25
     26
     27         #assert result.model_dump() == expected_response

this has happened a lot to me lately in different scenarios.

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