Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python3 Lettuce throws SyntaxError

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?

like image 890
Pani Avatar asked Sep 16 '16 08:09

Pani


2 Answers

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.

like image 92
Martijn Pieters Avatar answered Nov 13 '22 07:11

Martijn Pieters


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

See also the github discussion.

like image 2
serv-inc Avatar answered Nov 13 '22 08:11

serv-inc