Testing a standalone management command

The line between unit and integration is blurry. Just test what you need to for confidence.

I’d do it all in Python:

  1. set up the temporary directory with pathlib / pytest’s tmp_path fixture
  2. run your command with subprocess.run, or just by calling main
  3. assert on the file contents using pathlib API