[pytest-dev] What is the best practice for tests that install python packages and run their tests?

Anatoly Bubenkov bubenkoff at gmail.com
Sat Jun 23 10:51:27 EDT 2018


Hey Vasily,
I think pytest-cloud <https://github.com/pytest-dev/pytest-cloud> approach
can be useful for you, as it spreads virtual env to all test nodes
automatically

On Thu, Jun 21, 2018 at 11:35 AM Vasily Kuznetsov <kvas.it at gmail.com> wrote:

> Hello, everyone!
>
> Some time ago I wrote a pytest plugin [1] that helps with testing of
> scripts declared by 'console_scripts' entry point in setup.py. The tests of
> this plugin install a test package (let's call it TP) and then run TP's
> tests that are verifying that the scripts declared by TP's setup.py work as
> expected. TP is installed into the same python environment that runs the
> outer tests (uninstalled at fixture cleanup) and then the inner tests are
> run with the same pytest instance that runs the outer tests. This approach
> is somewhat dirty, but it works fine with disposable virtualenvs that we
> get from Tox.
>
> In the process of trying to package this plugin for Fedora it turned out
> that my test approach doesn't work with the way they run tests. They use
> system python so my tests try to install things into system python, don't
> have permissions and fail (see [2]).
>
> I think this could be fixed by creating a virtualenv in tmpdir and using
> that to install TP and run its tests. However, this new virtualenv would
> need to have pytest and pytest-console-scripts installed in it in order to
> run the inner tests. I'm planning to look into the ways to make a
> virtualenv inherit packages from another virtualenv (or from system python,
> as would be the case with Fedora package testing) but before I go into all
> this, I thought I would ask around if maybe there's a better way.
>
> Have any of you had situations where your tests needed to install packages
> and run their tests and how did you go about this?
>
> Thanks,
> Vasily
>
> [1]: https://pypi.org/project/pytest-console-scripts/
> [2]: https://github.com/kvas-it/pytest-console-scripts/issues/11
> _______________________________________________
> pytest-dev mailing list
> pytest-dev at python.org
> https://mail.python.org/mailman/listinfo/pytest-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20180623/1e1a82ca/attachment.html>


More information about the pytest-dev mailing list