Files
dvc/tests/unit/test_daemon.py
T
Saugat Pachhai a172067c7d fix errors raised by pylint (#6081)
astroid==2.5.7 has improved inference and was throwing
errors that were false negatives before. Fixing these
and ignoring some.

Also added `funcy.decorator` to the `signature-mutators`,
as it changes function signature (i.e. provides `Call` as
a first argument which is not required to pass).

Example errors that we were getting because of this:

```
tests/remotes/gdrive.py:40:11: E1120: No value for argument 'tries' in function call (no-value-for-parameter)
************* Module dvc.stage.serialize
dvc/stage/serialize.py:38:1: E1120: No value for argument 'func' in
function call (no-value-for-parameter)
************* Module dvc.fs.http
dvc/fs/http.py:19:1: E1120: No value for argument 'ctx' in function call (no-value-for-parameter)
************* Module dvc.fs.gdrive
dvc/fs/gdrive.py:66:11: E1120: No value for argument 'tries' in function call (no-value-for-parameter)
dvc/fs/gdrive.py:459:5: E1120: No value for argument 'ctx' in function call (no-value-for-parameter)
```
2021-05-31 05:46:18 +00:00

41 lines
1.2 KiB
Python

import inspect
import os
from unittest import TestCase
import mock
from dvc import daemon
class TestDaemon(TestCase):
@mock.patch("dvc.daemon._spawn_posix")
@mock.patch("dvc.daemon._spawn_windows")
def test(self, mock_windows, mock_posix):
daemon.daemon(["updater"])
if os.name == "nt":
mock_posix.assert_not_called()
mock_windows.assert_called()
args = mock_windows.call_args[0]
else:
mock_windows.assert_not_called()
mock_posix.assert_called()
args = mock_posix.call_args[0]
env = args[1]
self.assertTrue("PYTHONPATH" in env.keys())
file_path = os.path.abspath(inspect.stack()[0][1])
file_dir = os.path.dirname(file_path)
test_dir = os.path.dirname(file_dir)
dvc_dir = os.path.dirname(test_dir)
self.assertEqual(env["PYTHONPATH"], dvc_dir)
self.assertEqual(env[daemon.DVC_DAEMON], "1")
def test_no_recursive_spawn():
with mock.patch.dict(os.environ, {daemon.DVC_DAEMON: "1"}):
with mock.patch("dvc.daemon._spawn") as mock_spawn:
daemon.daemon(["updater"])
mock_spawn.assert_not_called()