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

Bad Test #11

Open
dfee opened this issue Sep 23, 2017 · 0 comments
Open

Bad Test #11

dfee opened this issue Sep 23, 2017 · 0 comments

Comments

@dfee
Copy link
Member

dfee commented Sep 23, 2017

FYI: this test will never run (or it will always run, but it shouldn't).

I'm in the process of porting this to aiohttp and found this...

I believe the test is all kinds of wrong.

  • its name doesn't match what it does (it has nothing to do with pretty printing)
  • I don't understand why 'request' would resolve to {}. I'd assume it'd be repr'd to <Request ...>

I believe the test ought to test that 'CUSTOM CONTEXT' is replaced with an empty dict. at least that's what the code will do when get_context(request) is called and it discovers that self.context is not a dict.

Here's my replacement test (note, this isn't written for sanic, but the premise holds):

    @pytest.mark.asyncio
    async def test_context_remapped(self, client, url_builder):
        response = await client.get(url_builder(query='{context}'))

        _json = await response.json()
        assert response.status == 200
        assert 'request' in _json['data']['context']
        assert 'CUSTOM CONTEXT' not in _json['data']['context']
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