-
Notifications
You must be signed in to change notification settings - Fork 2.4k
MockTarget mode fixed to accept read and write like r* or w* #2519
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you look into why Travis failed? Thanks!
* MockTarget mode fixed to accept read and write like r* or w* * Update mock_test.py * mock_test write bytes test fixed for python 3 * default mode added on MockTarget and default mode and none error tests added on MockFileTest
test/mock_test.py
Outdated
b.write("bar") | ||
except TypeError as error: | ||
self.assertIsNotNone(error) | ||
self.assertIn("'NoneType' object", str(error)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this test use assertRaises
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
test/mock_test.py
Outdated
with t.open(None) as b: | ||
b.write("bar") | ||
except TypeError: | ||
self.assertRaises(TypeError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with this being in an except
, we can't guarantee that the assertion is risen
i was expecting
t = MockTarget("foo")
with self.assertRaises(TypeError):
with t.open(None) as b:
b.write("bar")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, going to refactor it then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Appreciate the quick revisions! Sorry to not be conclusive (in my review) the first time around
No problem, it was my first time doing a PR to an open source project and I was able to learn more of python :) |
* upstream-master: Add Python 3.7 compatibility (spotify#2466) Refactor s3 copy into sub-methods (spotify#2508) Remove s3 bucket validation prior to file upload (spotify#2528) Version 2.7.9 set upper bound of python-daemon Update MockTarget mode to accept r* or w* (spotify#2519)
Description
I changed the mock target class to accept open modes such as rb, rt, wb and others
Motivation and Context
I did it because I am testing some luigi tasks using pickle and the wb wasn't working because of the mode == 'w' instead of mode[0] == 'w' comparation
Have you tested this? If so, how?
I have included a test for bytearray at mock_test.py