I need to patch a test method and have a path that so long that it goes above E501 80 symbols limit. Change of package name is not possible due dependencies elsewhere.
A sample of the problem:
from unittest.mock import patch
class TestSomething:
@patch(
"someveryveryveryveryveryveryveryveryveryveryveryveryveryverylongpath.to.a.method"
)
def test_something(self, mock_method): ...
Using f-string beforehand like this:
import someveryveryveryveryveryveryveryveryveryveryveryveryveryverylongpath as svl
imp_path = f"{svl.__name__}.to.a.method"
class TestSomething:
@patch(imp_path)
def test_something(self, mock_method): ...
fails, too.
A code sample to reproduce the problem:
from unittest.mock import patch
import matplotlib as mpl
imp_path = f"{mpl.__name__}.pyplot"
@patch(imp_path)
def qwe(mock_path):
mock_path.plot([1, 2, 3])
mock_path.show()
mock_path.savefig()
qwe()
Any idea would be appreciated.