Skip to content
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

Remove dependency on mox3 #182

Closed
mrbean-bremen opened this issue May 9, 2017 · 10 comments
Closed

Remove dependency on mox3 #182

mrbean-bremen opened this issue May 9, 2017 · 10 comments
Assignees

Comments

@mrbean-bremen
Copy link
Member

See discussion in #179 - mox3 support is dropped by OpenStack as stated by @dmsimard, and mock is included in unittest since Python 3.3.
We may have a second go at this replacement (see #48 for the first try).

@mrbean-bremen
Copy link
Member Author

I made a first version (mostly re-doing the previous changes) in https://github.com/mrbean-bremen/pyfakefs/tree/use-mock.
@jmcgeheeiv - what kind of tests would you suggest additionally to make sure that this works, or to reproduce the problems? I have seen the issue you mentioned about unittest.main.os not being patched, but I'm not sure if or why this is a problem for the library usage - can you give me an example?

@jmcgeheeiv
Copy link
Contributor

jmcgeheeiv commented May 9, 2017

I was just thinking this would need its own issue.

As I recall, the example I gave in mock issue 250 is not an issue for pyfakefs. I believe I gave that example merely because it used a public file familiar to the mock maintainers.

As I recall (and as described in mock issue 250), the problem with mock is that it stores names instead of references. So if thereafter the name is shadowed, you get something different when you look up the name. mox does not have this problem, and it has performed flawlessly.

After I added my fabulous (to me, at least) port to mock, it was with great disappointment that I backed it out and returned to mox. While I would be delighted to see my creation resurrected as you have done, if any module shadows a name that we are patching, as unittest did in the example, pyfakefs will not work on it.

Since mox3 is winding down, we do need to eliminate it as a dependency. I encourage you to simply fork the patch portion of mox3 (and its tests) and add it to pyfakefs. It works for us, and whatever patcher we use, it is completely internal to pyfakefs so client programmers will not notice the difference.

If you are looking for glory, fix mock. That would make you a hero.

@mrbean-bremen
Copy link
Member Author

Ok, using the stubber from mox3 sounds reasonable, if the mock problem is what you describe. I'm not from the stuff heroes are made of, so I think I will leave mock alone for the time being, and go the easy way. This may take some time, though...

@jmcgeheeiv
Copy link
Contributor

jmcgeheeiv commented May 9, 2017

This is a fairly slow moving event, so that is fine. My impression is that the only files you need are mox3/stubout.py and the corresponding test. Leave them as separate files.

@mrbean-bremen
Copy link
Member Author

Ok, thanks - I may check this tomorrow, if I find the time.

@mrbean-bremen mrbean-bremen changed the title Replace mox3 by mock Remove dependency on mox3 May 10, 2017
@mrbean-bremen
Copy link
Member Author

Ok - the stubout part that we need turned out to be surprisingly small and simple, and, other than the whole mox3, does not have any additional dependencies. I copied it over into pyfakes (will make a PR in a minute), and it works as expected.
I could not add the tests, as they depend on mox3, so I will check how to write tests for stubout. Also, I did not change the documentation in the file - I'm not sure what we are supposed to add if we use a part of another library (also under Apache license) - I would appreciate your help here.

@jmcgeheeiv
Copy link
Contributor

jmcgeheeiv commented May 10, 2017

I suggest leaving the stubout inline documentation as-is. Then leave it out of the pyfakefs documentation, as pyfakefs users cannot see stubout.

A few tests that simulate fake_filesystem_unittest.Patcher should be adequate. You might draw inspiration from fake_filesystem_unittest_test.

@mrbean-bremen
Copy link
Member Author

Ok, thanks - I will do this another day with a clear head.

@mrbean-bremen
Copy link
Member Author

I added a few tests - please check if this is sufficient.

@mrbean-bremen mrbean-bremen self-assigned this May 12, 2017
@mrbean-bremen
Copy link
Member Author

Fixed per #183.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants