#18 Experimental: Enable all resources during selftest
Opened 4 years ago by churchyard. Modified 4 years ago
tests/ churchyard/python resources  into  master

file modified
+1 -1
@@ -21,4 +21,4 @@ 

  # https://bugs.python.org/issue38815


  $PYTHON -m test.pythoninfo

- $PYTHON -m test -wW -j$JOBS $X

+ xvfb-run $PYTHON -m test -u all -wW -j$JOBS $X

file modified
@@ -61,3 +61,4 @@ 

      - python3-tkinter

      - python3-test

      - python3-debug

+     - xorg-x11-server-Xvfb

@vstinner Could you please look at the test failure?

Metadata Update from @churchyard:
- Request assigned

4 years ago

FAIL-str_selftest37.log: both failures seem to be related to Tk and fonts:

FAIL: test_fontlist_key (idlelib.idle_test.test_configdialog.FontPageTest)
Traceback (most recent call last):
  File "/usr/lib64/python3.7/idlelib/idle_test/test_configdialog.py", line 104, in test_fontlist_key
    self.assertNotEqual(down_font, font)
AssertionError: 'Cantarell' == 'Cantarell'

FAIL: test_from (tkinter.test.test_tkinter.test_widgets.ScaleTest)
Traceback (most recent call last):
  File "/usr/lib64/python3.7/tkinter/test/test_tkinter/test_widgets.py", line 867, in test_from
    self.checkFloatParam(widget, 'from', 100, 14.9, 15.1, conv=float_round)
  File "/usr/lib64/python3.7/tkinter/test/widget_tests.py", line 109, in checkFloatParam
    self.checkParam(widget, name, value, conv=conv, **kwargs)
  File "/usr/lib64/python3.7/tkinter/test/widget_tests.py", line 64, in checkParam
    self.assertEqual2(widget[name], expected, eq=eq)
  File "/usr/lib64/python3.7/tkinter/test/widget_tests.py", line 48, in assertEqual2
    self.assertEqual(actual, expected, msg)
AssertionError: 14.9 != 15.0


2 tests failed:
    test_idle test_tk

AssertionError: 'Cantarell' == 'Cantarell'

Maybe more fonts should be installed for the test?

The test has:

        if d.fontlist.size() < 2:
            self.skipTest('need at least 2 fonts')

I am mostly confused by the second failure.

FAIL: test_fontlist_key (idlelib.idle_test.test_configdialog.FontPageTest)

I reported the issue upstream: https://bugs.python.org/issue39600

FAIL: test_from (tkinter.test.test_tkinter.test_widgets.ScaleTest)

The Scale widget is implemented in Lib/tkinter/__init__.py:

class Scale(Widget):
    """Scale widget which can display a numerical scale."""

    def __init__(self, master=None, cnf={}, **kw):
        """Construct a scale widget with the parent MASTER.

        Valid resource names: activebackground, background, bigincrement, bd,
        bg, borderwidth, command, cursor, digits, fg, font, foreground, from,
        highlightbackground, highlightcolor, highlightthickness, label,
        length, orient, relief, repeatdelay, repeatinterval, resolution,
        showvalue, sliderlength, sliderrelief, state, takefocus,
        tickinterval, to, troughcolor, variable, width."""
        Widget.__init__(self, master, 'scale', cnf, kw)

Setting the "from" attributes is done by:

    def _configure(self, cmd, cnf, kw):
        """Internal function."""
        if kw:
            cnf = _cnfmerge((cnf, kw))
        elif cnf:
            cnf = _cnfmerge(cnf)
        if cnf is None:
            return self._getconfigure(_flatten((self._w, cmd)))
        if isinstance(cnf, str):
            return self._getconfigure1(_flatten((self._w, cmd, '-'+cnf)))
        cmd = _flatten((self._w, cmd)) + self._options(cnf)

    def configure(self, cnf=None, **kw):
        """Configure resources of a widget.

        The values for resources are specified as keyword
        arguments. To get an overview about
        the allowed keyword arguments call the method keys.
        return self._configure('configure', cnf, kw)

    def __setitem__(self, key, value):
        self.configure({key: value})

Getting the attribute is done by:

    def cget(self, key):
        return self.tk.call(self._w, 'cget', '-' + key)

    __getitem__ = cget

At the C level, tk.call() converts Python objects to Tcl object using static Tcl_Obj* AsObj(PyObject *value). Code for float:

    if (PyFloat_Check(value))
        return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value));

I understand that the "from" attribute is implemented in C. I don't know why it's rounded differently.

I'm unable to reproduce the other failure manually on Fedora 31:

vstinner@apu$ xvfb-run python3 -m test -v test_tk -v -u all -m 'tkinter.test.test_tkinter.test_widgets.ScaleTest.*'
test_activebackground (tkinter.test.test_tkinter.test_widgets.ScaleTest) ... ok
test_background (tkinter.test.test_tkinter.test_widgets.ScaleTest) ... ok
test_bigincrement (tkinter.test.test_tkinter.test_widgets.ScaleTest) ... ok
test_from (tkinter.test.test_tkinter.test_widgets.ScaleTest) ... ok
Tests result: SUCCESS

Where do we take it from here?