Does it make sense to install my Python unit tests in site-packages?

前端 未结 3 1668
一生所求
一生所求 2021-02-02 17:40

I\'m developing my first Python distribution package. My learning curve on Python packaging seems to be leveling off a bit, but I\'m still wrestling with a few open questions. O

3条回答
  •  攒了一身酷
    2021-02-02 18:02

    However I am no expert, I would like to share my opinion.

    I would always put tests alongside the code if I expect something might fail depending on the external reasons. Be it bit-order, strange time zones, character coding, 24-bit integers or anything else bizarre you can encounter and have a test for.

    Who would not be happy to download the source and run tests? Maybe some debian users that packages are stripped from sources (I know you are talking about python but let me be a little bit general) and your library can occasionally fail due to some strange things in the system.

    If your tests ensure internal sanity only, I would skip attaching them, as with out sources they are not worth much, since you will never alter the internals of the library.

    Personally, I've heard about a thing failing cause it was moved to some IBM machine which had different bit-ordering. I don't remember if it depended on bit operation or had something pre-computed and cached statically. But it is sometimes wise to check whether you load what you think you saved.

    EDIT: Maybe it will be better to rephrase it. I would install tests when you feel there might be portability caveats. I think it is always good to check things when you deploy stuff on a different system.

提交回复
热议问题