8000 MockTarget mode fixed to accept read and write like r* or w* by PedroRossi · Pull Request #2519 · spotify/luigi · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Sep 24, 2018

Conversation

PedroRossi
Copy link
Contributor

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

Copy link
Collaborator
@dlstadther dlstadther left a 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
@PedroRossi PedroRossi reopened this Sep 13, 2018
b.write("bar")
except TypeError as error:
self.assertIsNotNone(error)
self.assertIn("'NoneType' object", str(error))
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

with t.open(None) as b:
b.write("bar")
except TypeError:
self.assertRaises(TypeError)
Copy link
Collaborator

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")

Copy link
Contributor Author

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

Copy link
Collaborator
@dlstadther dlstadther left a 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

@PedroRossi
Copy link
Contributor Author

No problem, it was my first time doing a PR to an open source project and I was able to learn more of python :)

@dlstadther dlstadther merged commit b35e8bc into spotify:master Sep 24, 2018
dlstadther added a commit to dlstadther/luigi that referenced this pull request Sep 28, 2018
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0