Skip to content

Commit ee45d21

Browse files
committed
don't mock os.getpid() and os.getppid() (#180)
This avoids masking missing implementations, e.g. `os.getppid()` on Windows and Python 2.7 closes #180
1 parent 5ce9c6b commit ee45d21

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/client/client_tests.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ def test_service_info(elasticapm_client):
7474

7575

7676
def test_process_info(elasticapm_client):
77-
with mock.patch('os.getpid') as mock_pid, \
78-
mock.patch('os.getppid') as mock_ppid, \
79-
mock.patch.object(sys, 'argv', ['a', 'b', 'c']):
80-
mock_pid.return_value = 123
81-
mock_ppid.return_value = 456
77+
with mock.patch.object(sys, 'argv', ['a', 'b', 'c']):
8278
process_info = elasticapm_client.get_process_info()
83-
assert process_info['pid'] == 123
84-
assert process_info['ppid'] == 456
79+
assert process_info['pid'] == os.getpid()
80+
if hasattr(os, 'getppid'):
81+
assert process_info['ppid'] == os.getppid()
82+
else:
83+
# Windows + Python 2.7
84+
assert process_info['ppid'] is None
8585
assert process_info['argv'] == ['a', 'b', 'c']
8686

8787

0 commit comments

Comments
 (0)