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

Enhancement: give mock_open readline() and readlines() methods #61669

Closed
abadger mannequin opened this issue Mar 18, 2013 · 4 comments
Closed

Enhancement: give mock_open readline() and readlines() methods #61669

abadger mannequin opened this issue Mar 18, 2013 · 4 comments
Assignees
Labels
type-feature A feature request or enhancement

Comments

@abadger
Copy link
Mannequin

abadger mannequin commented Mar 18, 2013

BPO 17467
Nosy @abadger, @voidspace
PRs
  • bpo-35717: Fix KeyError exception raised when using enums and compile #11523
  • bpo-35717: Fix KeyError exception raised when using enums and compile #11523
  • bpo-35717: Fix KeyError exception raised when using enums and compile #11523
  • Superseder
  • bpo-23004: mock_open() should allow reading binary data
  • Files
  • python3-mock_open-methods.patch: Patch mock_open to understand readline and readlines methods
  • 01000-mock_open-methods.patch: 2nd version of mock_open readline/readlines patch
  • 01000-mock_open-methods.patch: 3rd version of the mock_open patch -- docs and read/readline/readlines draw from the same read_data
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/voidspace'
    closed_at = <Date 2013-03-20.00:22:57.778>
    created_at = <Date 2013-03-18.20:09:13.694>
    labels = ['type-feature']
    title = 'Enhancement: give mock_open readline() and readlines() methods'
    updated_at = <Date 2019-01-11.17:00:44.507>
    user = 'https://github.com/abadger'

    bugs.python.org fields:

    activity = <Date 2019-01-11.17:00:44.507>
    actor = 'remi.lapeyre'
    assignee = 'michael.foord'
    closed = True
    closed_date = <Date 2013-03-20.00:22:57.778>
    closer = 'python-dev'
    components = []
    creation = <Date 2013-03-18.20:09:13.694>
    creator = 'a.badger'
    dependencies = []
    files = ['29454', '29479', '29484']
    hgrepos = []
    issue_num = 17467
    keywords = ['patch', 'needs review']
    message_count = 4.0
    messages = ['184512', '184642', '184664', '184714']
    nosy_count = 3.0
    nosy_names = ['a.badger', 'michael.foord', 'python-dev']
    pr_nums = ['11523', '11523', '11523']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = '23004'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue17467'
    versions = ['Python 3.4']

    @abadger
    Copy link
    Mannequin Author

    abadger mannequin commented Mar 18, 2013

    unittest.mock provides a mock_open convenience function1. The convenience function handled file.read() but does not handle file.readline() or file.readlines(). I'll attach a patch that adds support for both of these methods.

    @abadger
    Copy link
    Mannequin Author

    abadger mannequin commented Mar 19, 2013

    Updated patch that includes unittests and fixes readlines() newline behaviour.

    @voidspace voidspace self-assigned this Mar 19, 2013
    @voidspace voidspace added the type-feature A feature request or enhancement label Mar 19, 2013
    @abadger
    Copy link
    Mannequin Author

    abadger mannequin commented Mar 19, 2013

    3rd version of the patch.

    • Added some documentation to untitest.mock.rst
    • Changed the code so that read, readline, and readlines all deplete the same copy of read_data.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 20, 2013

    New changeset 684b75600fa9 by Michael Foord in branch 'default':
    Closes bpo-17467. Add readline and readlines support to unittest.mock.mock_open
    http://hg.python.org/cpython/rev/684b75600fa9

    @python-dev python-dev mannequin closed this as completed Mar 20, 2013
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant