Cleanup of files generated by tests are kind of broken
Current state
I have a test which runs InitNode
. It cause, that in test's directory InitNode0/
directory was created and node's data were put there.
When I rerun this test, function scope DOES NOT clean anything. InitNode
runs again, but just before it cleans it's own directory. It is handled in code by lines (in test_tools/package/test_tools/__private/node.py
, Node.run
method):
if not self.__produced_files and self.directory.exists():
shutil.rmtree(self.directory)
Note, that above behavior works since 1.5 year on all tester's setups and nobody reports any problem with that
Problematic behavior
Now, after few runs of above test I decided to replace InitNode
with ApiNode
. So ApiNode
creates directory ApiNode0
and generates its data there. So where is the problem?
When tester opens directory generated_during_<this test>
, they will see both: ApiNode0/
directory from last run (that's good) and outdated InitNode0/
directory, which were left from a run before last. This confuses a tester. InitNode0/
directory will be never deleted (except, when tester will again create some InitNode
in their test).
Solution
I suggest to always remove whole test directory at the beginning of TestTools' function_scope
fixture (test_tools/package/test_tools/__private/scope/scope_fixtures_definitions.py
).
request
fixture.