2

I have a task queue processing service that I'm trying to run pytest function testing on. When running it in 'production', I start this from the command line, e.g. python main.py.

I can't figure out how to start this task service from pytest to do function testing on it. How do I start up the service inside pytest so that I can then add a job to it and see if the job gets processed and added to the database when completed?

def main():
    store = "jobs"
    worker_id = 1
    # Process tasks
    task_processing[store] = multiprocessing.Process(
            target=process_tasks, args=(store, worker_id)
        )
    nanopub_processing[store].start()


if __name__ == "__main__":
    main()

2
  • from main import main; main()? Commented Aug 11, 2019 at 20:27
  • Arrgghhh!!! I imported main and then ran main() and skipped a level - maybe that will teach me to name things better. Please post that as the answer and I'll accept it. Commented Aug 13, 2019 at 11:37

1 Answer 1

1

Just make sure you access the main function correctly:

from main import main

def test_main():
    main()
    ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.