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

unittest loader.py TypeError when code directory contains a socket #69507

Closed
VictorvandenElzen mannequin opened this issue Oct 5, 2015 · 10 comments
Closed

unittest loader.py TypeError when code directory contains a socket #69507

VictorvandenElzen mannequin opened this issue Oct 5, 2015 · 10 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@VictorvandenElzen
Copy link
Mannequin

VictorvandenElzen mannequin commented Oct 5, 2015

BPO 25320
Nosy @rbtcollins, @ezio-melotti, @voidspace
Files
  • patch-with-test.patch
  • patch-with-seperate-test.patch
  • 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 = None
    closed_at = <Date 2016-03-15.00:37:01.949>
    created_at = <Date 2015-10-05.16:43:44.763>
    labels = ['type-bug', 'library']
    title = 'unittest loader.py TypeError when code directory contains a socket'
    updated_at = <Date 2016-04-07.20:16:51.903>
    user = 'https://bugs.python.org/VictorvandenElzen'

    bugs.python.org fields:

    activity = <Date 2016-04-07.20:16:51.903>
    actor = 'Mike Miller'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-03-15.00:37:01.949>
    closer = 'rbcollins'
    components = ['Library (Lib)']
    creation = <Date 2015-10-05.16:43:44.763>
    creator = 'Victor van den Elzen'
    dependencies = []
    files = ['40825', '40826']
    hgrepos = []
    issue_num = 25320
    keywords = ['patch']
    message_count = 10.0
    messages = ['252342', '252825', '253249', '253250', '255193', '257263', '261790', '261791', '261792', '263002']
    nosy_count = 6.0
    nosy_names = ['rbcollins', 'ezio.melotti', 'michael.foord', 'python-dev', 'Victor van den Elzen', 'Mike Miller']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25320'
    versions = ['Python 3.5', 'Python 3.6']

    @VictorvandenElzen
    Copy link
    Mannequin Author

    VictorvandenElzen mannequin commented Oct 5, 2015

    Hi, when trying to run tests after upgrading from Python 3.4 to Python 3.5 I encountered the following exception:

    Traceback (most recent call last):
      ...
      File "/usr/lib/python3.5/unittest/loader.py", line 341, in discover
        tests = list(self._find_tests(start_dir, pattern))
      File "/usr/lib/python3.5/unittest/loader.py", line 398, in _find_tests
        full_path, pattern, namespace)
    TypeError: 'NoneType' object is not iterable

    This was caused by a stray socket in my code directory, and the fact that _find_test_path only considers directories and regular files.

    I attached a suggested fix that just skips all special files. No tests other than "it works on my machine".

    @VictorvandenElzen VictorvandenElzen mannequin added the stdlib Python modules in the Lib dir label Oct 5, 2015
    @rbtcollins
    Copy link
    Member

    The fix is appropriate (we might want to think about symlinks in the future). I'd very much like a test for it (in Lib/unittest/test/test_discovery.py) and it should be applied to 3.5, master - older versions had this wrapped up in simpler code and won't fail like this.

    @VictorvandenElzen
    Copy link
    Mannequin Author

    VictorvandenElzen mannequin commented Oct 20, 2015

    patch-with-test.patch is a patch against current tip (c3cec0f77eff+). It applies cleanly to 3.5.

    It seemed simplest to include the socket in test_find_tests.

    @VictorvandenElzen
    Copy link
    Mannequin Author

    VictorvandenElzen mannequin commented Oct 20, 2015

    Alternatively, patch-with-seperate-test.patch creates a seperate function to test for this issue.

    @VictorvandenElzen
    Copy link
    Mannequin Author

    VictorvandenElzen mannequin commented Nov 23, 2015

    Ping

    @ezio-melotti
    Copy link
    Member

    The fix looks ok, however the test seem to contain unnecessary code and it duplicates most of the previous test.
    I left a more detailed review on rietveld (see the "review" link next to the patch).

    @ezio-melotti ezio-melotti added the type-bug An unexpected behavior, bug, or error label Jan 1, 2016
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 15, 2016

    New changeset efc9836e0c83 by Robert Collins in branch '3.5':
    bpo-25320: Handle sockets in directories unittest discovery is scanning.
    https://hg.python.org/cpython/rev/efc9836e0c83

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 15, 2016

    New changeset 1d72402c1c91 by Robert Collins in branch 'default':
    bpo-25320: Handle sockets in directories unittest discovery is scanning.
    https://hg.python.org/cpython/rev/1d72402c1c91

    @rbtcollins
    Copy link
    Member

    Thanks for the patch; the test may be redundant but not enough to matter for now - and the bug really doth need fixing, so I've applied it as-is.

    @MikeMiller
    Copy link
    Mannequin

    MikeMiller mannequin commented Apr 7, 2016

    Just as a side note, the patch also works for soft links that point to files that don't exist. Thanks for getting this fixed!

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants