[Biopython-dev] Need guidance.

Peter Cock p.j.a.cock at googlemail.com
Thu Jun 15 09:33:19 UTC 2017


Hi Adil,

You've certainly learnt lots about imports and doctests - and probably
know more than me now.

I think you've made a sensible choice in restricting the special cases
to your new test_testseq.py while leaving run_tests.py and the
existing doctests as they are.

Biopython is likely to keep supporting Python 2.7 until the year 2020, see:

http://mailman.open-bio.org/pipermail/biopython-dev/2016-December/021613.html

Peter

On Thu, Jun 15, 2017 at 5:43 AM, Adil Iqbal <aiqbal85 at gmail.com> wrote:
> Hey, though I managed to solve the importing issue, in my conversation with
> Peter, I realized I made a rather large decision without consulting the
> community.
>
> In my current build, I am omitting all modules that are not part of the Bio
> package from executing doctests in version 2.7.
>
> My reason for doing that is copy-pasted below this message. Please read it
> for context.
>
> I realize that 'testseq' is the only module this change effects but is it
> something that we should extend to future modules?
>
> Best,
> Adil
>
> That method will certainly succeed in importing the ['testseq'] module. The
> issue is that once the importing is complete, the doctests are run. And the
> doctest also contain an import statement. The doctests cause an error in 2.7
> because they are subject to the same importing limitations as
> "run_tests.py". I will now describe these limitations below:
>
> Prior to 3.3, hierarchical importing (with "dot" notation) required a
> directory to be initialized with a "__init__.py" file. With the introduction
> of 3.3, hierarchical importing was generalized to all directories,
> regardless of initialization. This is why my commits were passing all tests
> except 2.7.
>
> Since we can't initialize folders carelessly, its best to remove the non-Bio
> modules from the "run_tests.py" file just prior to version 3.3. All versions
> of python after-and-including 3.3 don't require an extra "__init__.py" file,
> so the doctests will run fine on 3.3, 3.4, 3.5, and 3.6. That's why the most
> recent build passed the Travis CI test.
>
> I agree that my import methods were becoming overly-complicated. In the most
> recent build, I've eliminated the complicated code in favor of just deleting
> non-Bio files.The only complicated code left is limited to just the unit
> test ("test_testseq.py").
>
> Thankfully, the unit test for 'testseq' runs all of the same tests that are
> in the doctests, so we can be confident that 'testseq' is compatible with
> all versions of python. In the future, if "biopython" decides to stop
> supporting python 2.7, I would be happy to remove the last bit of
> complicated code.
>
> TL:DR - In 2.7 only: Modules outside 'Bio' package can be imported from
> "run_tests.py", however, their doctests will likely fail because they must
> also contain import statements. It's best to remove them from doctesting in
> earlier versions of python and allow the unit tests to confirm
> compatibility. (Only for non-Bio files in only 2.7).
>
>
>
>
> _______________________________________________
> Biopython-dev mailing list
> Biopython-dev at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython-dev


More information about the Biopython-dev mailing list