Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DRMacIver opened this issue Mar 10, 2023 · 0 comments

Comments

@DRMacIver
Copy link

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
}
Ren-hongchen added a commit to Ren-hongchen/requests that referenced this issue Mar 14, 2023
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 a pull request may close this issue.

1 participant