Sunday, 19 November 2023

What exactly PyCharm Django Test run configuration do

I have a custom test command in my Django project:

class Command(test.Command):
    def add_arguments(self, parser):
        super(Command, self).add_arguments(parser)
        parser.add_argument(
            "--fit",
            action="store_true",
            help="Fit persistent tests instead of checking them.",
        )

    def handle(self, *test_labels, **options):
        if options["fit"]:
            ...
        super(Command, self).handle(*test_labels, **options)

It works when running from the console, e.g. python manage.py test --fit.

However, when I'm using a PyCharm Django Tests configuration, it does not execute the handle(...) method. I can add --fit flag as an option and I can't add some random --qwerty flag. So, it means that the command is registered. While running in debug mode, I could reach the point in the add_arguments(...), but not in the handle(...) (as well as not in the django.core.management.commands.test.Command.handle(..), by the way).

The only problem is that PyCharm executes this command some other way, without calling handle(...) method. So the question is - maybe someone know, what PyCharm is actually calling?



from What exactly PyCharm Django Test run configuration do

No comments:

Post a Comment