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 https://packagecontrol.io/packages/PyTest 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.
Sublime text PyTest Package
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
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/pytest_exec.pyâ, 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?
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 https://github.com/packagecontrol/channel/commit/f85773475ff930e2419ce1ef6527bb19e814b9e8
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 https://pypi.org/project/lxml/4.2.6/#files?
Prior to that Package Control used https://github.com/eerohele/sublime-lxml which is is a repackaged 4.1 4.1.1 would be also available on pypi: https://pypi.org/project/lxml/4.1.1/#files
Letâs invite @deathaxe who is more familiar with PC libraries (he wrote it ) 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 https://github.com/eerohele/sublime-lxml 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.
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. https://github.com/wbond/package_control_channel/pull/8911
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
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 https://github.com/wbond/package_control_channel/pull/8911 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.