Skip to content

Replace Source with dedent where possible#3864

Merged
asottile merged 1 commit intopytest-dev:masterfrom
asottile:source_to_dedent
Aug 23, 2018
Merged

Replace Source with dedent where possible#3864
asottile merged 1 commit intopytest-dev:masterfrom
asottile:source_to_dedent

Conversation

@asottile
Copy link
Member

I also manually reindented a lot of tqs literals since black munged them

I only touched ./testing as to avoid changing public behaviour

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 92.638% when pulling 85482d5 on asottile:source_to_dedent into 6f73655 on pytest-dev:master.

@nicoddemus
Copy link
Member

Cool @asottile! 👍

assert f.statement == _pytest._code.Source("")
finally:
f.code.__class__.fullsource = prop
with mock.patch.object(f.code.__class__, "fullsource", None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use monkeypatch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops didn't see this until already merged -- monkeypatch has a much wider scope than the code I was replacing and so it is not equivalent.

(And since this is monkeypatching a pytest internal I don't really want that to leak out of this test)

Curious also why to prefer monkeypatch over mock.patch -- the latter is much more battle tested and has a well defined patch scope due to the with block

@asottile asottile merged commit 52fa8c9 into pytest-dev:master Aug 23, 2018
@asottile asottile deleted the source_to_dedent branch August 23, 2018 17:45
@asottile asottile mentioned this pull request Aug 24, 2018
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

Successfully merging this pull request may close these issues.

5 participants