Sublime Forum

Sublime text PyTest Package


I am having troubles with pytest package, namely I installed this package because I have some work to do regarding paython testers and absolutely hate switching to vs code when I am on sublime because I hate vs code and find sublime amazing. So I am trying to setup my pytest development for my work on sublime and I am having trouble. I installed this package as it is the only one as far as I know that is available for running python tests using pytest and not using unit testing. The package works fine but it is not showing any annotations when the test actually fails which is the worst thing because I deperately need it. On their package website and github repository there are images and gifs where this is showing and working but not for me. I have tried pretty much everything and googled anything that I could but still cannot figure this one out so I am asking for help if anyone knows how to fix this. Thanks you.



I’m the author. Just checked, still works for me, e.g.

Maybe you have a different pytest/python version? And it just broke. Have you checked the console? The plugin is so old, don’t even know how to configure this? LOL



I used pytest 7.4.3 for the pic.



Sorry for late reply, hmm nope checked it nothing, I am not sure, does the plugin display if the tester is written wrong or when a function fails a test, because it doesn’t display anything to me. I am having pytest 8.1.1 version, I am not sure if I should downgrade it and don’t even know how I would do that.
Runnin the test works, it displays the tester results in a console but doesn’t display any annotations inside the tester code.



IIRC the plugin runs pytest, telling it to (also) write the output to an xml file which we then parse and transform to annotations. Doesn’t the standard Sublime Text console show any errors? (View -> Show Console).



Did you change any defaults? I can imagine not all --tb formats having enough information to really annotate the source. Default is --tb=auto -l; -l == show-locals.



So in the console it says : Run pytest --tb=auto -l “”
Traceback (most recent call last):
File “/Users/karlosiric/Library/Application Support/Sublime Text 3/Installed Packages/PyTest.sublime-package/”, line 182, in parse_result
ImportError: No module named ‘lxml’

This is the error I am getting, I don’t know what this lxml file is suppose to be.



lxml is the python library to parse xml. It should be installed. Have you used Package Control? Are you on ST3 or a recent build?



E.g. Package Control: Satisfy Libraries/Packages should install lxml.



I am using ST4, hmm I have checked now it says all packages are installed, but when I check for librarires it says one or more libraries could not be installed, says in the console the following:
Package Control: The library “lxml” is not available for Python 3.3 on this platform, or this version of Sublime Text

So I guess on sublime text 4 it’s not working.



It should work on ST4. This is likely introduced by

which updates lxml to 4.2.6 but I don’t see a Mac release for python33 for that version. Do you see it here

Prior to that Package Control used which is is a repackaged 4.1 4.1.1 would be also available on pypi:

Let’s invite @deathaxe who is more familiar with PC libraries (he wrote it :grin:) and also did the above commit.



No as far as I can see it only has Intel macOSX version, I am not sure if it will be compatible with my silicone m1 tho. I can give it a try tommorow and I will let you know the result if @deathaxe doesn’t answer till then.



I haven’t seen any python 3.3 package with compiled modules, which supports M1. Arm64 whl files are not provided for python versions before 3.8 via pypi. Also the mensioned does not.

For python 3.8 lxml 5.2.1 universal2 is shipped for Mac Sillicon.



Shouldn’t the compatibility software translate on the fly. python33/the ST host is probably not compiled for M1 too.

What version does PC install for linux here? On Windows I have 4.2.6 but I don’t see a manylinux version for py33 as well.



Well, just checked, it downloads 4.2.1 on linux. It shouldn’t use different versions on different OSes, imo, that doesn’t make writing against the library easier. For the legacy, 33 host, not touching/updating is imo the preferred way as it is always less risky, except if we need to apply security patches of course.



PC searches and publishes the latest available version on each platform. There’s nothing we can do, If pypi doesn’t provide whl files for all plattforms per release.

That said, lxml 5.2.1 is deployed on py38 for all plattforms.

It’s just py33 which versions differ. But there are no compatibility issues expected between micro-versions. 4.2.1 vs. 4.2.6.

With py3.3 being eol for years, you can’t expect packages to still support them. Vice versa time doesn’t stop due to ST still supporting 3.3. So versions between 3.3/3.8 differ for sure.



4.2.1 typically has a bug that got fixed in 4.2.6. :blush:

That said, if we always get the newest version we get breaking changes without asking for it. That was in principal possible before, but these updates were manual and thus unlikely to happen often. To be slow here is a good thing as long as the ST community is that slow as well.

Anyway, let’s just try to lift PyTest to the 38 host.

1 Like


So basically with all being said, there is no lxml which works with my given version of python and pytest on macOS, so PyTest on sublime in my case canno’t have annotations? I don’t have a problem with it I can read the output from the terminal display when I run the tests it’s just I miss the feel of annotations :frowning:



Nah, not necessarily. It depends on your experience. You can just install a python33 and install/compile lxml into the lib folder


Or you wait until gets merged, after that I push a new version of Pytest running on py38. For py38, PC will have a compiled Apple Silicon lxml.



Hmm , nice to know yeah. Although I will probably wait for it to released for mac M1 silicone since I use the pytest just fine without annotations so it’s not that big of a deal for me at the moment. I also use the terminal every now and then and display the test there sometimes, it’s just smoother and brighter so I can see the error’s more easily. I have a quick question tho, maybe a bit off the topic but I figured why not ask anyway, do you know of any libraries/packages that can be used to maybe highlight the pytest errors better in the terminal, like to make the output errors more flashy/colorized for easier orientation and readability.