Skip to content

testTmpExists fails if TMPDIR != /tmp on Linux #810

@mgorny

Description

@mgorny

Describe the bug
When TMPDIR is not /tmp (or a subdirectory of /tmp), the following test failure occurs:

======================================================================
FAIL: testTmpExists (pyfakefs.tests.fake_filesystem_unittest_test.TestTempDirCreation)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/pyfakefs/pyfakefs/tests/fake_filesystem_unittest_test.py", line 666, in testTmpExists
    self.assertTrue(os.path.exists("/tmp"))
AssertionError: False is not true

I think this is because https://github.com/pytest-dev/pyfakefs/blob/main/pyfakefs/fake_filesystem_unittest.py#L894-L903 only creates /tmp symlink on Darwin (and only TMPDIR on Linux) but https://github.com/pytest-dev/pyfakefs/blob/main/pyfakefs/tests/fake_filesystem_unittest_test.py#L663-L666 assumes /tmp on all non-win32 platforms.

How To Reproduce

export TMPDIR=/var/tmp
tox

Your environment
Please run the following in the environment where the problem happened and
paste the output.

python -c "import platform; print(platform.platform())"
python -c "import sys; print('Python', sys.version)"
python -c "from pyfakefs.fake_filesystem import __version__; print('pyfakefs', __version__)"
python -c "import pytest; print('pytest', pytest.__version__)"
Linux-6.2.10-gentoo-dist-x86_64-AMD_Ryzen_5_3600_6-Core_Processor-with-glibc2.37
Python 3.11.3 (main, Apr  6 2023, 04:25:37) [GCC 12.2.1 20230304]
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name '__version__' from 'pyfakefs.fake_filesystem' (/tmp/pyfakefs/pyfakefs/fake_filesystem.py)
pytest 7.3.0

(git 1906fde)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions