I have made my custom management command called pytest_wrp
So when I call
python manage.py test
This bit of code is called:
class Command(test.Command):
def handle(self, *args, **options):
super(Command, self).handle(*args, **options) # this calls the python manage.py test
self.stdout.write("My code starts from here.")
management.call_command(pytest_wrp.Command(), '--pact-files="{argument}"'.format(argument=path_to_file), '--pact-provider-name="MyService"', verbosity=0)
The pytest_wrp
basically has this code in it:
class Command(BaseCommand):
help = "Runs tests with Pytest"
def add_arguments(self, parser):
parser.add_argument("args", nargs=argparse.REMAINDER)
def handle(self, *args, **options):
pytest.main(list(args)) # This doesn't accept the pact args, even if you specify a "--" separator
But this calls pytest
not pytest-django
Hence the extra arguments that I am passing don't get recognized and pytest can't start the test suite.
I wanna pass the extra arguments for some of the test cases. If there is some way to call pytest-django directly and pass the extra arguments in code that would be optimal.