Skip to content

test_zipped_paths_extracted fails if test file has been modified since last run #6377

Open
@DRMacIver

Description

@DRMacIver

If you run python -m pytest tests/test_utils.py -ktest_zipped_paths_extracted this test will pass normally. If you run it again, it will pass again.

If, however, you make any modifications to the file, the test will now fail and keep failing:

E       AssertionError: assert False
E        +  where False = <function cmp at 0x7f4ea6d4dab0>('/tmp/test_utils.py', '/home/david/project-reducer/scratch/requests/tests/test_utils.py')
E        +    where <function cmp at 0x7f4ea6d4dab0> = filecmp.cmp

The reason for this is that the last time the test ran, the contents of __file__ were written to /tmp/test_utils.py and when extract_zipped_paths is next called, it doesn't overwrite the existing file, so the filecmp fails because it's now comparing against the old version of the file.

Expected Result

The test should run successfully when modifications to the file are made.

Actual Result

Modifications to the test file that are unrelated to the test in question cause it to fail.

Reproduction Steps

python -m pytest tests/test_utils.py -ktest_zipped_paths_extracted
echo -n '# modification' >> tests/test_utils.py
python -m pytest tests/test_utils.py -ktest_zipped_paths_extracted

System Information

$ python -m requests.help
{
  "chardet": {
    "version": "5.1.0"
  },
  "charset_normalizer": {
    "version": "3.0.1"
  },
  "cryptography": {
    "version": ""
  },
  "idna": {
    "version": "3.4"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.10.8"
  },
  "platform": {
    "release": "5.15.90.1-microsoft-standard-WSL2",
    "system": "Linux"
  },
  "pyOpenSSL": {
    "openssl_version": "",
    "version": null
  },
  "requests": {
    "version": "2.28.2"
  },
  "system_ssl": {
    "version": "1010106f"
  },
  "urllib3": {
    "version": "1.26.14"
  },
  "using_charset_normalizer": false,
  "using_pyopenssl": false
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions