Skip to content

Commit

Permalink
Removed extra create_file from troubleshooting snippet (#875)
Browse files Browse the repository at this point in the history
* Removed extra create_file from troubleshooting snippet
* Fixed wording from type to attributes
* Removed pytest.mark.usefixtures usage as it distracted from point
  • Loading branch information
jamesbraza authored Aug 26, 2023
1 parent 0472d41 commit 48608b4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ passed before the ``mocker`` fixture to ensure this:
Pathlib.Path objects created outside of tests
---------------------------------------------
An pattern which is more often seen with the increased usage of `pathlib` is the
creation of global `pathlib.Path` objects (instead of string paths) that are imported
An pattern which is more often seen with the increased usage of ``pathlib`` is the
creation of global ``pathlib.Path`` objects (instead of string paths) that are imported
into the tests. As these objects are created in the real filesystem,
they are not of the same type as faked `pathlib.Path` objects,
they do not have the same attributes as fake ``pathlib.Path`` objects,
and both will always compare as not equal,
regardless of the path they point to:

Expand All @@ -254,7 +254,7 @@ regardless of the path they point to:
def test_path_equality(fs):
# This Path was made after the fake filesystem is set up,
# and thus patching within pathlib is in effect
fake_file_path = pathlib.Path(fs.create_file(FILE_PATH).path)
fake_file_path = pathlib.Path(str(FILE_PATH))
assert FILE_PATH == fake_file_path # fails, compares different objects
assert str(FILE_PATH) == str(fake_file_path) # succeeds, compares the actual paths
Expand Down

0 comments on commit 48608b4

Please sign in to comment.