-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Failing to mock duplicity._librsync #2387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Just to follow up, I have tried mocking with:
separately and together. I have tried the autodoc_mock_imports option on the above as well. I've used mock.Mock() and mock.MagicMock() in combination with above to no success. Can anyone point me to an answer that works on the net? I think I have gone through all of the bogus ones mentioning [python, mock, package, module] and tried them all with no luck. There are a lot of answers out there, but ferreting out the real answers seems to be impossible. |
I think there are no a generic solution for this. The one listed in the FAQ seems to be one that works in the most common cases but there are some libraries that requires more research. Please, if you find the solution share it here. |
The solution was like this, in librsync.py:
if os.environ.get('READTHEDOCS') == 'True':
import mock
import duplicity
duplicity._librsync = mock.MagicMock()
and this in setup.py:
if not os.environ.get('READTHEDOCS') == 'True':
ext_modules=[Extension("duplicity._librsync",
["duplicity/_librsyncmodule.c"],
include_dirs=incdir_list,
library_dirs=libdir_list,
libraries=["rsync"])]
...Thanks,
...Ken
…On Wed, Mar 8, 2017 at 7:11 PM, Manuel Kaufmann ***@***.***> wrote:
I think there are no a generic solution for this. The one listed in the
FAQ seems to be one that works in the most common cases but there are some
libraries that requires more research. pygame is one of them as listed in #2511
(comment)
<#2511 (comment)>
and this one is another *special* case.
Please, if you find the solution share it here.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2387 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJpUEVsj9lrKxTnpxmJa3a4zncwCf5Yks5rj1G8gaJpZM4JuBtr>
.
|
Thank you a lot. Since the issue is solved I'm closing this one. Feel free to reopen it if you have any issue. |
Details
Expected Result
Successful dummy import of duplicity._librsync
Actual Result
import of still fails.
I tried the example in your FAQ. It works with lockfile, but does not work with a nested module. duplicity needs to remain imported, just to dummy out _librsync, without changing the code of librsync if possible. I have read the answers on the net, but none of them seem to involve mocking out a complete submodule. Is that even possible?
...Thanks,
...Ken
The text was updated successfully, but these errors were encountered: