Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
Update the environ shim to be compatible with Python 3.9 (#98)
Browse files Browse the repository at this point in the history
* Tests incompatible with latest pytest

* Update environ shim to be compatible with Python 3.9

The `os.putenv()` and `os.unsetenv()` are always available starting in Python
3.9, removing the need for special handling in the `os._Environ` mapping:
python/cpython@b8d1262

Update the environ shim to match.
  • Loading branch information
andni233 authored Jul 14, 2021
1 parent 388e194 commit 743bde8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
29 changes: 20 additions & 9 deletions pytest_parallel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,26 @@ def pytest_configure(config):

class ThreadLocalEnviron(os._Environ):
def __init__(self, env):
super().__init__(
env._data,
env.encodekey,
env.decodekey,
env.encodevalue,
env.decodevalue,
env.putenv,
env.unsetenv
)
if sys.version_info >= (3, 9):
super().__init__(
env._data,
env.encodekey,
env.decodekey,
env.encodevalue,
env.decodevalue,
)
self.putenv = os.putenv
self.unsetenv = os.unsetenv
else:
super().__init__(
env._data,
env.encodekey,
env.decodekey,
env.encodevalue,
env.decodevalue,
env.putenv,
env.unsetenv
)
if hasattr(env, 'thread_store'):
self.thread_store = env.thread_store
else:
Expand Down
1 change: 0 additions & 1 deletion tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def test_async_2():


@pytest.mark.parametrize('cli_args', [
[],
['--workers=2'],
['--tests-per-worker=2']
])
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ envlist =
py36
py37
py38
py39

[testenv]
deps =
pytest>=3.0
pytest>=3.0,<6.0
pytest-html>=1.19.0
six>=1.11.0
tblib
Expand Down

0 comments on commit 743bde8

Please sign in to comment.