Repository: beeware/briefcase

Issue:
CI Failures on Windows for Python 3.12.0a5
### Describe the bug

CI is [failing]( https://github.com/beeware/briefcase/actions/runs/4126241832/jobs/7129016817) on Windows for (recently released) Python 3.12.0a5.

```
==============================================================================
FAIL: tests/platforms/android/gradle/test_create.py::test_extract_packages[test_sources8-"leading"]
------------------------------------------------------------------------------
test_sources=['//leading']
app.test_sources=['//leading']
{'extract_packages': '""',
 'safe_formal_name': 'First App',
 'version_code': '100'}

Traceback (most recent call last):
  File "C:\Users\user\github\beeware\briefcase\tests\platforms\android\gradle\test_create.py", line 112, in test_extract_packages
    assert context["extract_packages"] == expected
AssertionError: assert '""' == '"leading"'
  - "leading"
  + ""

==============================================================================
FAIL: tests/platforms/android/gradle/test_create.py::test_extract_packages[test_sources21-"leading"]
------------------------------------------------------------------------------
test_sources=['\\\\leading']
app.test_sources=['\\\\leading']
{'extract_packages': '""',
 'safe_formal_name': 'First App',
 'version_code': '100'}

Traceback (most recent call last):
  File "C:\Users\user\github\beeware\briefcase\tests\platforms\android\gradle\test_create.py", line 112, in test_extract_packages
    assert context["extract_packages"] == expected
AssertionError: assert '""' == '"leading"'
  - "leading"
  + ""

------------------------------------------------------------------------------
```
(output augmented to include additional information)

### Steps to reproduce

Run [CI](https://github.com/beeware/briefcase/actions/workflows/ci.yml).

### Expected behavior

CI should succeed.

I believe this CPython [change](https://github.com/python/cpython/pull/100351) is causing this new behavior.

I am not entirely sure what is necessary to resolve this, though. Based on the CPython fix, these are not really valid paths for Windows.

Notably, this CPython fix was [backported](https://github.com/python/cpython/pull/100999) to 3.11.

### Screenshots

_No response_

### Environment

- Operating System: Windows 10
- Python version: `3.12.0a5`
- Software versions:
  - Briefcase: `0.3.13.dev33+g8d503064.d20230208`


### Logs

_No response_

### Additional context

_No response_

Discussion:

Patch:
diff --git a/changes/1087.misc.rst b/changes/1087.misc.rst
new file mode 100644
index 00000000..96df9f5a
--- /dev/null
+++ b/changes/1087.misc.rst
@@ -0,0 +1,1 @@
+Handle differences in UNC path parsing when generating extractPackages.
diff --git a/src/briefcase/platforms/android/gradle.py b/src/briefcase/platforms/android/gradle.py
index 8d6406f3..e528af1b 100644
--- a/src/briefcase/platforms/android/gradle.py
+++ b/src/briefcase/platforms/android/gradle.py
@@ -179,7 +179,9 @@ class GradleCreateCommand(GradleMixin, CreateCommand):
             # Extract test packages, to enable features like test discovery and assertion
             # rewriting.
             "extract_packages": ", ".join(
-                f'"{Path(path).name}"' for path in (app.test_sources or [])
+                f'"{name}"'
+                for path in (app.test_sources or [])
+                if (name := Path(path).name)
             ),
         }
 


Test patch:
diff --git a/tests/platforms/android/gradle/test_create.py b/tests/platforms/android/gradle/test_create.py
index ce0cc300..a331effa 100644
--- a/tests/platforms/android/gradle/test_create.py
+++ b/tests/platforms/android/gradle/test_create.py
@@ -78,19 +78,35 @@ def test_version_code(create_command, first_app_config, version, build, version_
 
 extract_packages_params = [
     ([], ""),
+    ([""], ""),
     (["one"], '"one"'),
     (["one/two"], '"two"'),
+    (["one//two"], '"two"'),
     (["one/two/three"], '"three"'),
     (["one", "two"], '"one", "two"'),
     (["one", "two", "three"], '"one", "two", "three"'),
     (["one/two", "three/four"], '"two", "four"'),
     (["/leading"], '"leading"'),
-    (["//leading"], '"leading"'),
     (["/leading/two"], '"two"'),
+    (["/leading/two/three"], '"three"'),
     (["trailing/"], '"trailing"'),
     (["trailing//"], '"trailing"'),
     (["trailing/two/"], '"two"'),
 ]
+
+# Handle differences in UNC path parsing (https://github.com/python/cpython/pull/100351).
+extract_packages_params += [
+    (
+        ["//leading"],
+        ""
+        if sys.platform == "win32" and sys.version_info >= (3, 11, 2)
+        else '"leading"',
+    ),
+    (["//leading/two"], "" if sys.platform == "win32" else '"two"'),
+    (["//leading/two/three"], '"three"'),
+    (["//leading/two/three/four"], '"four"'),
+]
+
 if sys.platform == "win32":
     extract_packages_params += [
         ([path.replace("/", "\\") for path in test_sources], expected)