Git Product home page Git Product logo

Comments (6)

joeyespo avatar joeyespo commented on August 11, 2024

Oh wow, that would be problematic. Thanks for opening the issue.

Tests should absolutely have the ability to be run in parallel though. I wonder if this particular symptom is a case of hard-coding the test database path when you should really be using a random temp file (or sqlite:///:memory:).

Would using one of those techniques fix the test database already exists problem?

from pytest-watch.

Glueon avatar Glueon commented on August 11, 2024

pytest-django automatically creates and gives names to databases. It supports xdist out of the box so maybe it understands that if tests run in parallel it should create several different databases.

But when you manually spin up two py.test instances in parallel it has zero knowledge about this, therefore it tries to create a django_pytest_1 db for the first test and fails because another py.test instance has already created it. xdist does not run tests twice.

That's only my guess but I think that this unwapted py.test process duplication is a problem which can theoretically lead to all sorts of problems.

from pytest-watch.

joeyespo avatar joeyespo commented on August 11, 2024

Nice, I didn't know pytest-django created databases that way. Thanks for clarifying that.

xdist also has the ability to run multiple subprocesses, so pytest-watch shouldn't have a problem with that either.

It seems like a low-level design flaw if running py.test twice causes the tests to fail. That's why I suggested creating a fresh database (as opposed to creating a "database" with a unique name within an existing database system--it seems you can only really do this with sqlite or by running postgresql / mysql within a Docker container), since it's analogous to an Immutable Server.

As for pytest-watch, it's possible to patch the underlying problem by waiting for the previous test process to finish. But since I see that as a disadvantage (since the full test suite will be run each time you press "save"), I wonder if there's a middleground. Perhaps when a restart is detected, a "stop" signal can be sent to the existing test process, and then we wait for that process to stop before running the tests again.

What do you think about that approach?

from pytest-watch.

Glueon avatar Glueon commented on August 11, 2024

Isn't it possible to block pytest-watch from restarting if py-test dropped into the IPDB session or is running? Like we disussed earlier.

from pytest-watch.

ethanmcc avatar ethanmcc commented on August 11, 2024

I'm having a similar problem. I think waiting for the initial test to respond to the stop signal would be sufficient, and more optimal than waiting for the entire suite to finish.

from pytest-watch.

joeyespo avatar joeyespo commented on August 11, 2024

Merging this into the more general issue #36.

Thanks for your thoughts on this.

from pytest-watch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.