Skip to content

Commit c21a1f4

Browse files
thunzenazarewk
authored andcommitted
python313Packages.tkinter: patch failing ttk test for python <3.12
python/cpython#124378 python/cpython#124542
1 parent 1a56a1d commit c21a1f4

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

pkgs/development/python-modules/tkinter/default.nix

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,28 @@ buildPythonPackage {
2727
cp -rv Modules/clinic ../tkinter/
2828
cp -rv Lib/tkinter ../tkinter/
2929
30-
pushd $NIX_BUILD_TOP/tkinter
31-
3230
# install our custom pyproject.toml
3331
cp ${
3432
replaceVars ./pyproject.toml {
3533
python_version = python.version;
3634
python_internal_dir = "${python}/include/${python.libPrefix}/internal";
3735
}
38-
} ./pyproject.toml
36+
} $NIX_BUILD_TOP/tkinter/pyproject.toml
3937
4038
''
4139
+ lib.optionalString (pythonOlder "3.13") ''
42-
substituteInPlace "tkinter/tix.py" --replace-fail \
40+
substituteInPlace "$NIX_BUILD_TOP/tkinter/tkinter/tix.py" --replace-fail \
4341
"os.environ.get('TIX_LIBRARY')" \
4442
"os.environ.get('TIX_LIBRARY') or '${tclPackages.tix}/lib'"
4543
'';
4644

45+
# Adapted from https://github.com/python/cpython/pull/124542
46+
patches = lib.optional (pythonOlder "3.12") ./fix-ttk-notebook-test.patch;
47+
48+
preConfigure = ''
49+
pushd $NIX_BUILD_TOP/tkinter
50+
'';
51+
4752
build-system = [ setuptools ];
4853

4954
buildInputs = [
@@ -81,7 +86,7 @@ buildPythonPackage {
8186
if pythonOlder "3.12" then
8287
[
8388
"test.test_tk"
84-
# "test.test_ttk_guionly" # https://github.com/python/cpython/issues/124378
89+
"test.test_ttk_guionly"
8590
]
8691
else
8792
[
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--- a/Lib/tkinter/test/test_ttk/test_widgets.py
2+
+++ b/Lib/tkinter/test/test_ttk/test_widgets.py
3+
@@ -911,12 +911,20 @@ class ScrollbarTest(AbstractWidgetTest, unittest.TestCase):
4+
return ttk.Scrollbar(self.root, **kwargs)
5+
6+
7+
-@add_standard_options(IntegerSizeTests, StandardTtkOptionsTests)
8+
+@add_standard_options(StandardTtkOptionsTests)
9+
class NotebookTest(AbstractWidgetTest, unittest.TestCase):
10+
OPTIONS = (
11+
'class', 'cursor', 'height', 'padding', 'style', 'takefocus', 'width',
12+
)
13+
14+
+ def test_configure_height(self):
15+
+ widget = self.create()
16+
+ self.checkPixelsParam(widget, 'height', '10c', 402, -402, 0, conv=False)
17+
+
18+
+ def test_configure_width(self):
19+
+ widget = self.create()
20+
+ self.checkPixelsParam(widget, 'width', '10c', 402, -402, 0, conv=False)
21+
+
22+
def setUp(self):
23+
super().setUp()
24+
self.nb = self.create(padding=0)

0 commit comments

Comments
 (0)