diff --git a/pugsql/compiler.py b/pugsql/compiler.py index ea16da1..de4d194 100644 --- a/pugsql/compiler.py +++ b/pugsql/compiler.py @@ -53,7 +53,7 @@ def _add_path(self, sqlpath, encoding=None): if not os.path.isdir(sqlpath): raise ValueError('Directory not found: %s' % sqlpath) - for sqlfile in glob(os.path.join(sqlpath, '*sql')): + for sqlfile in sorted(glob(os.path.join(sqlpath, '*sql'))): with open(sqlfile, 'r', encoding=encoding) as f: pugsql = f.read() diff --git a/tests/test_compiler.py b/tests/test_compiler.py index ac65eb7..f0222bd 100644 --- a/tests/test_compiler.py +++ b/tests/test_compiler.py @@ -14,9 +14,9 @@ def test_sets_sqlpaths(self): def test_function_redefinition(self): msg = ( - 'Error loading tests/sql/duplicate-name/foo.sql - a SQL function ' + 'Error loading tests/sql/duplicate-name/foo2.sql - a SQL function ' 'named foo was already defined in ' - 'tests/sql/duplicate-name/foo2.sql.') + 'tests/sql/duplicate-name/foo.sql.') with pytest.raises(ValueError, match=msg): compiler.Module('tests/sql/duplicate-name')