test_ok2/testing/code
Ran Benita 81192ca85f pytester: use monkeypatch.chdir() for dir changing
The current method as the following problem, described by Sadra
Barikbin:

The tests that request both `pytester` and `monkeypatch` and use
`monkeypatch.chdir` without context, relying on `monkeypatch`'s teardown
to restore cwd. This doesn't work because the following sequence of
actions take place:

- `monkeypatch` is set up.
- `pytester` is set up. It saves the original cwd and changes it to a
  new one dedicated to the test function.
- Test function calls `monkeypatch.chdir()` without context.
  `monkeypatch` saves cwd, which is not the original one, before
  changing it.
- `pytester` is torn down. It restores the cwd to the original one.
- `monkeypatch` is torn down. It restores cwd to what it has saved.

The solution here is to have pytester use `monkeypatch.chdir()` itself,
then everything is handled correctly.
2023-09-25 11:31:09 +03:00
..
test_code.py code: simplify Code construction 2020-10-31 12:40:25 +02:00
test_excinfo.py pytester: use monkeypatch.chdir() for dir changing 2023-09-25 11:31:09 +03:00
test_source.py Drop Python 3.7 2023-06-30 14:55:42 -07:00