pw_build: Fix Python Tree Tests

There was a problem with this test if the setuptools-scm package was
installed inside the Pigweed virtualenv. An exception gets raised if
the fake pyproject.toml does not have a valid syntax:

  tomli.TOMLDecodeError: Expected "=" after a key in a key/value pair

The exception doesn't occur if setuptools-scm is not installed. It
can't hurt to use valid file contents for these tests so this change
does that.

Change-Id: I555297a21f42dd41bd962db51a556bcb6d42ed6e
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/80222
Reviewed-by: Joe Ethier <jethier@google.com>
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
diff --git a/pw_build/py/create_python_tree_test.py b/pw_build/py/create_python_tree_test.py
index 2314cc7..0f221f4 100644
--- a/pw_build/py/create_python_tree_test.py
+++ b/pw_build/py/create_python_tree_test.py
@@ -23,6 +23,7 @@
 
 from pw_build.python_package import PythonPackage
 from pw_build.create_python_tree import build_python_tree, copy_extra_files
+from pw_build.generate_python_package import _PYPROJECT_FILE as PYPROJECT_TEXT
 
 
 def _setup_cfg(package_name: str) -> str:
@@ -52,6 +53,9 @@
         text = f'"""{package_name}"""'
         if str(destination).endswith('setup.cfg'):
             text = _setup_cfg(package_name)
+        elif str(destination).endswith('pyproject.toml'):
+            # Make sure pyproject.toml file has valid syntax.
+            text = PYPROJECT_TEXT
         destination.write_text(text)