Skip to content

Add note in documentation to help modernize code bases to use pathlib#10331

Merged
nicoddemus merged 1 commit intopytest-dev:mainfrom
sgaist:add_modernization_tip_for_tmpdir_and_tmpdir_factory
Oct 8, 2022
Merged

Add note in documentation to help modernize code bases to use pathlib#10331
nicoddemus merged 1 commit intopytest-dev:mainfrom
sgaist:add_modernization_tip_for_tmpdir_and_tmpdir_factory

Conversation

@sgaist
Copy link
Contributor

@sgaist sgaist commented Oct 1, 2022

The legacypath plugin handles the tmpdir and tmpdir_factory which should be update to their modern counterparts that uses pathlib.

Disabling this plugin allows developer to easily find and thus update the use of these fixtures.

Fixes #10199


.. code-block:: bash

pytest -p no:legacypath-tmpdir
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be just -p no:legacypath?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question

I used the registered name defined in legacypath.py.

From a quick test:

def test_tmpdir(tmpdir):
      assert True
def test_tmpdir_factory(tmpdir_factory):
      assert True

either no:legacypath or no:legacypath-tmpdir triggers the expected error.

However, using pytest --trace-config, legacypath is listed there, so you are correct.

I will correct that.

@sgaist sgaist force-pushed the add_modernization_tip_for_tmpdir_and_tmpdir_factory branch from 763c61b to a28d595 Compare October 8, 2022 08:18
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Thanks!

@nicoddemus nicoddemus merged commit 784ba85 into pytest-dev:main Oct 8, 2022
@nicoddemus
Copy link
Member

@bluetech the backport workflow failed with:

HTTP 401: Bad credentials (https://api.github.com/graphql)

This is not supercritical to port right now, just mentioned in case you were not aware.

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.

Allow users to find usages of py.local

2 participants