pyx-project / pyx

Repository of PyX, a Python package for the creation of PostScript, PDF, and SVG files.
https://pyx-project.org/
GNU General Public License v2.0
109 stars 18 forks source link

test_text fails #37

Closed grozin closed 1 year ago

grozin commented 2 years ago
grozin@bilbo ~/tmp/pyx-master/test/functional $ python test_text.py 
ignoring special 'Warning: missing glyph `Gamma''
ignoring special 'Warning: missing glyph `Gamma''
ignoring special 'Warning: missing glyph `Gamma''
ignoring special 'Warning: missing glyph `Gamma''
Traceback (most recent call last):
  File "/home/grozin/tmp/pyx-master/test/functional/test_text.py", line 117, in <module>
    ue_pfm = text.UnicodeEngine(metric=text.UnicodeEngine.pfm_metric)
AttributeError: type object 'UnicodeEngine' has no attribute 'pfm_metric'

Indeed, class UnicodeEngine in pyx/text.py has only the attributes

>>> dir(pyx.text.UnicodeEngine)
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'preamble', 'reset', 'text', 'text_pt']

I had to comment out 2 lines in test/functional/test_text.py:

ue_pfm = text.UnicodeEngine(metric=text.UnicodeEngine.pfm_metric)
c.insert(ue_pfm.text(10, 8, "UnicodeEngine output (PFM)"))

then tests run successfully.

Using this occasion, I'd like to add 2 points:

  1. In pyx/text.py,

    r = self._wait(self._received.wait, self._received.isSet)

    isSet is deprecated, and should be replaced by is_set.

  2. In manual/colorname.py and manual/gradientname.py,

    lines = imp.find_module("color", pyx.__path__)[0].readlines()

    imp is deprecated, and importlib should be used instead. However, there is no exact equivalent of imp.find_module, and some thought is needed. I have not done it.