From 17fbe36a8e36f41ee233219ea04b42d02bb20c3a Mon Sep 17 00:00:00 2001 From: Connor Newton Date: Thu, 29 Aug 2024 21:46:45 +0100 Subject: [PATCH] Sort by name when iterating directories Resolve intermittently failing unit tests with the added bonus of more stable output. --- src/copyright2/filesystem.py | 2 +- tests/test_app.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/copyright2/filesystem.py b/src/copyright2/filesystem.py index 1188889..ca852be 100644 --- a/src/copyright2/filesystem.py +++ b/src/copyright2/filesystem.py @@ -62,7 +62,7 @@ def __iter__(self) -> Iterator[File]: exclude_dirs=self.cfg.exclude_dirs, ) - for path in self.path.iterdir(): + for path in sorted(self.path.iterdir()): if not filter.match(path): continue diff --git a/tests/test_app.py b/tests/test_app.py index b6a0766..9139240 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -44,9 +44,9 @@ def test_list_readme(examples_readme: None) -> None: assert result.stdout.splitlines() == [ "README.md", - "src/readme.py", - "src/ext/readme.h", "src/ext/readme.c", + "src/ext/readme.h", + "src/readme.py", "4", ]