PythonSTB commited on
Commit
acd75c4
·
verified ·
1 Parent(s): 59b3e10

Delete tkinter/Test_Tkinter.py

Browse files
Files changed (1) hide show
  1. tkinter/Test_Tkinter.py +0 -119
tkinter/Test_Tkinter.py DELETED
@@ -1,119 +0,0 @@
1
- """Test_Tkinter.py - device test for tkinter 8.6.14 Android wheels.
2
-
3
- IMPORT-LEVEL ONLY (no display needed, no Tk() call): sets up the Android
4
- bootstrap, imports the _tkinter extension, evaluates Tcl, and checks the
5
- vendored data. The GUI test (real Tk window via Termux:X11 DISPLAY) is a
6
- later device phase.
7
-
8
- Run on-device via PipManager Scripts folder after installing the matching
9
- tkinter wheel. Pattern: import _tk_android FIRST, then tkinter/_tkinter.
10
- Exit-code contract: exit 0 iff every check PASSes, else exit 1.
11
-
12
- Generated by RIMI
13
- """
14
- import os
15
- import sys
16
-
17
- PASS = 0
18
- FAIL = 0
19
-
20
-
21
- def check(name, cond, detail=""):
22
- global PASS, FAIL
23
- if cond:
24
- PASS += 1
25
- print("[PASS] %s %s" % (name, detail))
26
- else:
27
- FAIL += 1
28
- print("[FAIL] %s %s" % (name, detail))
29
-
30
-
31
- print("tkinter device test - python %s" % sys.version.split()[0])
32
-
33
- # 1. bootstrap import (env setup + native preload)
34
- try:
35
- import _tk_android
36
- check("import _tk_android", True, _tk_android.__file__)
37
- except Exception as e:
38
- check("import _tk_android", False, repr(e))
39
- print("RESULT: %d PASS, %d FAIL" % (PASS, FAIL))
40
- sys.exit(1)
41
-
42
- # 2. env vars point at bundled dirs
43
- try:
44
- here = os.path.dirname(os.path.abspath(_tk_android.__file__))
45
- ok = (os.environ.get("TCL_LIBRARY") == os.path.join(here, "tcl8.6")
46
- and os.environ.get("TK_LIBRARY") == os.path.join(here, "tk8.6")
47
- and os.environ.get("XLOCALEDIR") == os.path.join(here, "X11", "locale"))
48
- check("bootstrap env TCL/TK/XLOCALEDIR", ok,
49
- "TCL=%s" % os.environ.get("TCL_LIBRARY"))
50
- except Exception as e:
51
- check("bootstrap env TCL/TK/XLOCALEDIR", False, repr(e))
52
-
53
- # 3. fonts.conf generated
54
- try:
55
- fc = os.environ.get("FONTCONFIG_FILE", "")
56
- check("fonts.conf generated", os.path.isfile(fc), fc)
57
- except Exception as e:
58
- check("fonts.conf generated", False, repr(e))
59
-
60
- # 4. bundled natives present
61
- try:
62
- libs = [os.path.join(here, n) for n in ("libtcl8.6.so", "libtk8.6.so")]
63
- ok = all(os.path.isfile(p) and os.path.getsize(p) > 100000 for p in libs)
64
- check("bundled libtcl/libtk present", ok,
65
- "tcl=%d tk=%d" % tuple(os.path.getsize(p) if os.path.isfile(p) else -1 for p in libs))
66
- except Exception as e:
67
- check("bundled libtcl/libtk present", False, repr(e))
68
-
69
- # 5. _tkinter extension import (resolves from this wheel; app ships none)
70
- try:
71
- import _tkinter
72
- check("import _tkinter", True, _tkinter.__file__)
73
- except Exception as e:
74
- check("import _tkinter", False, repr(e))
75
- print("RESULT: %d PASS, %d FAIL" % (PASS, FAIL))
76
- sys.exit(1)
77
-
78
- # 6. headless Tcl interpreter (wantTk=0 -> no display needed)
79
- try:
80
- t = _tkinter.create("", "tkintertest", "Tk", 0, 0, 0, 0, None)
81
- check("headless Tcl interp (wantTk=0)", True, repr(t)[:60])
82
- except Exception as e:
83
- check("headless Tcl interp (wantTk=0)", False, repr(e))
84
- print("RESULT: %d PASS, %d FAIL" % (PASS, FAIL))
85
- sys.exit(1)
86
-
87
- # 7. Tcl patchlevel 8.6.14
88
- try:
89
- pl = t.call("info", "patchlevel")
90
- check("Tcl patchlevel 8.6.14", pl == "8.6.14", "got=%s" % pl)
91
- except Exception as e:
92
- check("Tcl patchlevel 8.6.14", False, repr(e))
93
-
94
- # 8. Tcl_Eval arithmetic
95
- try:
96
- r = t.call("expr", "6*7")
97
- check("Tcl expr 6*7=42", str(r) == "42", "got=%s" % r)
98
- except Exception as e:
99
- check("Tcl expr 6*7=42", False, repr(e))
100
-
101
- # 9. clock with tzdata (vendored tzdata/ required for -timezone)
102
- try:
103
- r = t.call("clock", "format", 0, "-format", "%Y-%m-%d",
104
- "-timezone", ":America/New_York")
105
- check("clock tzdata America/New_York", str(r) == "1969-12-31", "got=%s" % r)
106
- except Exception as e:
107
- check("clock tzdata America/New_York", False, repr(e))
108
-
109
- # 10. stdlib tkinter package still wins for .py (no shadowing) + Tk class
110
- try:
111
- import tkinter
112
- check("stdlib tkinter unshadowed", "tkinter" in tkinter.__file__ and hasattr(tkinter, "Tk"),
113
- tkinter.__file__[:80])
114
- except Exception as e:
115
- check("stdlib tkinter unshadowed", False, repr(e))
116
-
117
- print("NOTE: GUI test (Tk() window) needs Termux:X11 + DISPLAY=127.0.0.1:0 - later phase")
118
- print("RESULT: %d PASS, %d FAIL" % (PASS, FAIL))
119
- sys.exit(0 if FAIL == 0 else 1)