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

if TESTFN == "/tmp/@test", some tests fail #48090

Closed
ocean-city mannequin opened this issue Sep 11, 2008 · 5 comments
Closed

if TESTFN == "/tmp/@test", some tests fail #48090

ocean-city mannequin opened this issue Sep 11, 2008 · 5 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@ocean-city
Copy link
Mannequin

ocean-city mannequin commented Sep 11, 2008

BPO 3840
Nosy @bitdancer
Files
  • test_urllib.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 2013-03-18.07:15:24.214>
    created_at = <Date 2008-09-11.18:27:20.883>
    labels = ['type-bug', 'tests']
    title = 'if TESTFN == "/tmp/@test", some tests fail'
    updated_at = <Date 2013-03-18.07:15:24.213>
    user = 'https://bugs.python.org/ocean-city'

    bugs.python.org fields:

    activity = <Date 2013-03-18.07:15:24.213>
    actor = 'r.david.murray'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-03-18.07:15:24.214>
    closer = 'r.david.murray'
    components = ['Tests']
    creation = <Date 2008-09-11.18:27:20.883>
    creator = 'ocean-city'
    dependencies = []
    files = ['11468']
    hgrepos = []
    issue_num = 3840
    keywords = ['patch']
    message_count = 5.0
    messages = ['73047', '73051', '73055', '184418', '184434']
    nosy_count = 3.0
    nosy_names = ['ocean-city', 'r.david.murray', 'littleq0903']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue3840'
    versions = ['Python 2.6']

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Sep 11, 2008

    test_urllib's test_geturl fails with following messege.

    test_urllib
    test test_urllib failed -- Traceback (most recent call last):
      File "/home/WhiteRabbit/python-dev/trunk/Lib/test/test_urllib.py",
    line 84, in
     test_geturl
        self.assertEqual(self.returned_obj.geturl(), self.pathname)
    AssertionError: 'file:///tmp/@test' != '/tmp/@test'

    test_support.TESTFN is /tmp/@test on cygwin, and Lib/urllib.py(484,485)
    specially cares about leading slash.

                if file[:1] == '/':
                    urlfile = 'file://' + file

    If this is geturl()'s design, probably test should be changed like
    attached patch.

    @ocean-city ocean-city mannequin added the tests Tests in the Lib/test dir label Sep 11, 2008
    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Sep 11, 2008

    I cannot create patch now, but test_site error comes from same reason.

    test_support.TESTFN is /tmp/@test on cygwin

    After I applied following adhok patch, test passed.

    Index: Lib/test/test_site.py
    ===================================================================
    --- Lib/test/test_site.py (revision 66385)
    +++ Lib/test/test_site.py (working copy)
    @@ -126,7 +126,7 @@
    class PthFile(object):
    """Helper class for handling testing of .pth files"""

    -    def __init__(self, filename_base=TESTFN, imported="time",
    +    def __init__(self, filename_base="@test", imported="time",
                         good_dirname="__testdir__", bad_dirname="__bad"):
             """Initialize instance variables"""
             self.filename = filename_base + ".pth"

    site.py's addpackage() is doing

        fullname = os.path.join(sitedir, name)

    and on my cygwin, this equals to

        os.path.join(
            "/home/WhiteRabbit/python-dev/trunk/lib/test",
            "/tmp/@test.pth") #=> "/tmp/@test.pth"

    probably this is not good. (I cannot figure out what site.py is doing
    though)

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Sep 11, 2008

    Same happend in test_import.py too.

    test_support.TESTFN is /tmp/@test on cygwin
    This was false information. There was a directry named @test, so
    open(TESTFN, "w+") in test_support.py failed, "/tmp/@test" was used instead.

    Several tests seem to assume TESTFN is relative path (filename?), so
    maybe should we use @test2 as TESTFN if @test is not writable and vise
    versa? (Or simply test fails if @test is not writable)

    @ocean-city ocean-city mannequin changed the title test_urllib fails on cygwin if TESTFN == "/tmp/@test", some tests fail Sep 11, 2008
    @devdanzin devdanzin mannequin added the type-bug An unexpected behavior, bug, or error label May 17, 2009
    @littleq0903
    Copy link
    Mannequin

    littleq0903 mannequin commented Mar 18, 2013

    TESTFN will be in format "@test_{pid}_tmp" instead of "@test" right now.

    So it's not easy to have exactly the same name "@test_{pid}tmp" in case if you put "@test{X}_tmp" (for X in range(1,100000)) so many files into the top folder.

    does it need to keep open anymore?

    @bitdancer
    Copy link
    Member

    To clarify Colin's comment (we worked on this at the sprints), in 2.7 and later regrtest no longer will generate a TESTFN that starts with /tmp in any circumstance, so that includes cygwin. (Instead regrtest creates a temporary directory in which the tests are run.) So, indeed, this bug is now out of date.

    @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
    tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant