Skip to content

Commit 9a79747

Browse files
committed
Modify testbed app to support iOS.
1 parent 95ea7cf commit 9a79747

File tree

4 files changed

+33
-7
lines changed

4 files changed

+33
-7
lines changed

tests/testbed/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ requires = []
3535
[tool.briefcase.app.testbed.iOS]
3636
requires = [
3737
"rubicon-objc",
38+
"std-nslog",
3839
]
39-
template = "../../../../templates/briefcase-iOS-Xcode-template"
40-
# template_branch = "m1-compile"
40+
template_branch = "m1-compile"
4141
support_package = "../../dist/Python-3.10-iOS-support.custom.tar.gz"
4242

4343
[tool.briefcase.app.testbed.android]

tests/testbed/src/testbed/app.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""
22
A testbed for the Apple Support packages.
33
"""
4+
import importlib
45
import platform
56
import sys
67
import traceback
78

89
from . import common
9-
from . import macos
1010

1111

1212
def discover_tests(module):
@@ -24,10 +24,15 @@ def main():
2424
print(f"Python {platform.python_version()} Apple Support verification suite")
2525
print(f"Running on {platform.platform()}")
2626
print("=" * 80)
27-
# Discover the suite
27+
# Discover the common test suite
2828
suite = discover_tests(common)
29-
if sys.platform == "darwin":
30-
suite.extend(discover_tests(macos))
29+
30+
# Discover the platform-specific tests
31+
try:
32+
module = importlib.import_module(f".{sys.platform}", "testbed")
33+
suite.extend(discover_tests(module))
34+
except ModuleNotFoundError:
35+
print(f"No platform-specific tests for {sys.platform}")
3136

3237
# Run the suite
3338
failures = 0
@@ -52,4 +57,4 @@ def main():
5257

5358
print("=" * 80)
5459
print(f"Tests complete; {tests} tests, {failures} failures.")
55-
sys.exit(int(failures != 0))
60+
sys.exit(failures)

tests/testbed/src/testbed/ios.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from rubicon.objc import ObjCClass
2+
3+
from .utils import assert_
4+
5+
6+
UIResponder = ObjCClass('UIResponder')
7+
8+
# iOS apps need an AppDelegate or they crash
9+
class PythonAppDelegate(UIResponder):
10+
pass
11+
12+
13+
def test_subprocess():
14+
"Subprocesses should raise exceptions"
15+
import subprocess
16+
17+
try:
18+
subprocess.call(['uname', '-a'])
19+
raise AssertionError('Subprocesses should not be possible')
20+
except RuntimeError as e:
21+
assert_(str(e) == "Subprocesses are not supported on ios")

0 commit comments

Comments
 (0)