MartinPacker / filterCSV

Tools to manipulate CSV files in a format suitable for importing into various mindmapping programs - such as iThoughts, Freemind, and MindNode.
MIT License
32 stars 8 forks source link

Testing is blocked by code at global scope #3

Closed cclauss closed 4 years ago

cclauss commented 4 years ago

Python code should be in functions or indented under if __name__ == "__main__": to allow doctests (#2), unittests, pytests, etc. to run. This needs to be done so that the test in #2 can run successfully. Once this is done, we can create separate test files that can be executed via pytest.

cclauss commented 4 years ago

The way that testing is done in Python is that the file under test is imported (by doctest, unittest, pytest, etc.) and then tests are run on it. If there is blocking code that is in global scope then the import operation fails and the tests can never be started. While #2 is an extremely simple test, it adequately demonstrates that no tests can be run with so much code (460+ lines) being run at a global scope. We will need to put that code into functions or indent it under if __name__ == "__main__": so that it is not run when filterCSV is imported.

cclauss commented 4 years ago

Closed by #2.