ply icon indicating copy to clipboard operation
ply copied to clipboard

Guard unittest.main() invocation when test files are imported

Open echoix opened this issue 1 year ago • 0 comments

This PR simply adds a if __name__ == "__main__": guard to the unittest.main() call at the end of the two test files, tests/testlex.py and tests/testyacc.py.

This change happens to follow the pattern of the basic example in unittest's docs: https://docs.python.org/3/library/unittest.html#basic-example

With this, this allows to run the test suite normally with the included makefile, as well as with pytest, that can run unittest tests without any changes.

echoix avatar Oct 06 '24 12:10 echoix