Python3 Lettuce throws SyntaxError
Asked Answered
B

2

10

I am trying to use lettuce to write some simple Unit tests.
(More specifically I am following this tutorial: https://semaphoreci.com/community/tutorials/bdd-testing-a-restful-web-application-in-python)
I just installed lettuce with:

$ pip3 install lettuce

and when I run

$ lettuce test/features 

I get:

Traceback (most recent call last):
  File "/usr/local/bin/lettuce", line 9, in <module>
    load_entry_point('lettuce==0.2.23', 'console_scripts', 'lettuce')()
  File "/usr/local/lib/python3.4/site-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/usr/local/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.4/site-packages/lettuce/__init__.py", line 179
    print "Error loading step definitions:\n", e
                                        ^
SyntaxError: Missing parentheses in call to 'print'

Is there a mistake in the lettuce package? I went and corrected a few things(added parenthesis to some print statements and then some other prints failed for the same reason). Any ideas?

Burglar answered 16/9, 2016 at 8:28 Comment(1)
Looks like lettuce is not Python 3 compatible.Branum
B
9

Unfortunately for you, lettuce is not compatible with Python 3.

The project doesn't state anywhere what they are compatible with, but their source code is using Python 2 specific statements, like the print statement that triggered the exception. There are however more problems than just that print. There is an issue open asking for Python 3 support.

If you must use lettuce then you'll need to use Python 2.7 instead. Otherwise, there appears to be a fork called aloe that works with nose and Python 3.

Branum answered 16/9, 2016 at 8:35 Comment(0)
S
2

There is now a fork of lettuce that seems to work on Python 3.

See also the github discussion.

Sergent answered 20/6, 2019 at 9:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.