Sublime Forum

Sublime text PyTest Package

#1

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.

0 Likes

#2

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

0 Likes

#3

I used pytest 7.4.3 for the pic.

0 Likes

#4

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.

0 Likes

#5

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).

0 Likes

#6

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.

0 Likes

#7

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.

0 Likes

#8

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?

0 Likes

#9

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

0 Likes

#10

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.

0 Likes

#11

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 :grin:) and also did the above commit.

0 Likes

#12

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.

0 Likes

#13

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.

0 Likes

#14

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.

0 Likes

#15

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.

0 Likes

#16

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.

0 Likes

#17

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. https://github.com/wbond/package_control_channel/pull/8911

1 Like

#18

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:

0 Likes

#19

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

image

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.

0 Likes

#20

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.

0 Likes