Running a file other than the main file for Unit Testing
LeonGrin (15)

I created a test_main.py file to unit test the main.py file. But every time I click "Run", it only runs the main.py file. Is it possible to run a file other than the main file?

You are viewing a single comment. View All
mat1 (2510)

You could import test_main at the beginning of main.py to run test_main.py.
Please upvote this comment if it was helpful or useful in any way

LeonGrin (15)

@mat1 This import in the main file allows to run code of the test_main file when you call it on the main file. But what I want to do is to run the test_main file without writting calling it's code on the main file.

timmy_i_chen (962)

@LeonGrin Right now all repls run the main file to start; there's no way around that. :(

LeonGrin (15)

@timmy_i_chen thank you. Is it possible for 2 repls to interact with each other? Maybe this could be a workaround.

LeonGrin (15)

Hi @timmy_i_chen
I am trying to run a unit testing code from the file test_main.py, as you can see here: https://repl.it/@LeonGrin/Unit-Testing-in-Python-with-Replit
This repl is very simple. I am trying to figure out a way to run unit testing on Repl.it without having to insert all the unit testing code on the main.py file. Do you know how can I do this?
I feel that it might exist a very simple solution to my problem that I am not seeing.