Path: csiph.com!goblin3!goblin2!goblin.stu.neva.ru!aioe.org!bofh.it!news.nic.it!robomod From: Robert Collins Newsgroups: linux.debian.maint.python Subject: Re: Python < 3.5 tests Date: Thu, 08 Oct 2015 23:20:02 +0200 Message-ID: References: X-Original-To: Dmitry Shachnev X-Mailbox-Line: From debian-python-request@lists.debian.org Thu Oct 8 21:16:39 2015 Old-Return-Path: X-Amavis-Spam-Status: No, score=-7.681 tagged_above=-10000 required=5.3 tests=[BAYES_00=-2, LDO_WHITELIST=-5, MURPHY_DRUGS_REL8=0.02, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001] autolearn=ham autolearn_force=no X-Policyd-Weight: DYN_NJABL=ERR(0) NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .robertcollins. - helo: .mail-io0-f172.google. - helo-domain: .google.) FROM/MX_MATCHES_HELO(DOMAIN)=-2; rate: -7 X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=ckhRihc9+bmDR/VTYxpRrfZ6UpD7LIAd5niqmKyoNQ8=; b=PGynIO6wU1DjPp8O/K/SPK+rPlQ3OOdpCeu6A4co6yKckqcf13TBbOjepRBwp5m5Kg df1Zk3gAwR/FDAl2fBAbY52sIYrHgTtP159CQi7PbIW3aCKjsYNE33bJ7DFQFLlS4Dbz vyyg+GPJrDjXkPFIqSbzzEkEMW5KBHgMtabwnGr7epvzbcfA5UUsDVbueCY8qXAv8EeG ZfARw8tXwdo+Vpguv2e0jjAo0cIz2crVQXo7FnFXnNIErjvmQ2Ll9nVYlhGL7BwQ9xfR /YDoAsJYwzVyqOTeoOmERL86pMdDo5r+XpXZN+0sjipaoZMt1Wmaxg87Y2W5hc3N+Uyy ENxA== X-Gm-Message-State: ALoCoQl37zaQXZJu1Kzu3Zl8VjL2wQTRI84uNJA0A4i44VRZXYNo2SwUD+NL5jUFr9ZnD4MLgDeg MIME-Version: 1.0 X-Received: by 10.107.17.30 with SMTP id z30mr12969725ioi.97.1444338974871; Thu, 08 Oct 2015 14:16:14 -0700 (PDT) X-Originating-IP: [122.57.98.209] Content-Type: text/plain; charset=UTF-8 X-Mailing-List: archive/latest/12876 List-ID: List-URL: List-Archive: https://lists.debian.org/msgid-search/CAJ3HoZ2jWias_awhGHphGrnTRjemwH1gLw718HP+yPMWrhZYXg@mail.gmail.com Approved: robomod@news.nic.it Lines: 73 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Cc: Debian Python X-Original-Date: Fri, 9 Oct 2015 10:16:14 +1300 X-Original-Message-ID: X-Original-References: <20151007211222.GA16055@prune.in.vpac.org> <20151008114344.2592.41864@mitya57.me> Xref: csiph.com linux.debian.maint.python:7565 On 9 October 2015 at 00:43, Dmitry Shachnev wrote: > Hi all, > > On Thu, 8 Oct 2015 08:12:22 +1100, Brian May wrote: > [...] >> So it looks like it can't find the tests under Python 2.7 or Python 3.4, >> so it use to work, however under Python 3.5 it now does find the tests >> and they fail. >> >> This left me wondering: >> >> * Why does it not find the tests under Python 2.7, 3.4? What is >> different about Python 3.5 that it does? > > There was a change in unittest autoloader in Python 3.5. It now tries to > import the package even if it has no tests. I do not know if it is an > intended change, or a side-effect of fixing some bug ([1]?). Maybe Robert > can enlighten us here. Imagine I have a directory with __init__.py and test_foo.py, and a subdir (sub) of that with __init__.py and test_bar.py. Before that change, __init__ was loaded and test_foo was loaded. and sub/__init__ was loaded, then if present the load_tests hook in sub/__init__ is fire, and finally test_bar.py is loaded. After the change the root __init__ is examined for a load_tests hook as well. So the only time this specific patch would change behaviour is if discover's start dir was a package (vs a namespace package aka directory) and __init__ has a load_tests hook. As discover is being run with a start of ., thats not the impact here. But - ajax_select/__init__.py is going to be imported, and thats whats erroring. I don't think that this is a 3.5 unit testing change - I think its an error importing some bit of django. The test suite output should show the actual import error exception, whats been pasted here so far has just been the loader stage output, but the loader returns a thunk that will show the exception that occurred during loading and would help debugging. > This has caused some my packages to FTBFS too, for example see bugs > #800671 and #800139. So if it not an intended change, it should be fixed > upstream. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=800671 shows this: "/tmp/buildd/python-changelog-0.3.4/.pybuild/pythonX.Y_3.5/build/changelog/__init__.py", line 3, in from .changelog import setup File "/tmp/buildd/python-changelog-0.3.4/.pybuild/pythonX.Y_3.5/build/changelog/changelog.py", line 5, in from sphinx.util.compat import Directive ImportError: No module named 'sphinx' And pybuild has cd'd to the build dir there before running discover. So - changelog's __init__ can't be imported - that should occur in all versions of discover, when changelog is imported and scanned, because importing anything from within it will need to initialise the package first, which is basic Python semantics. 800139 has the same issue. Any tests of these packages will need to import the package itself to exercise it, so I don't see a CPython/discover bug here. -Rob -- Robert Collins Distinguished Technologist HP Converged Cloud