gabrielfalcao / lettuce

Behavior-driven-development tool for python, inspired by Cucumber for Ruby ⛺
http://lettuce.it
GNU General Public License v3.0
1.27k stars 323 forks source link

Initialisation error in Django project #557

Open mathewtrivett opened 6 years ago

mathewtrivett commented 6 years ago

I'm setting up lettuce to run integrations tests in a Django project. I have created a blank accounts.feature file and a blank accounts_steps.py file.

    ├── apps
    │   └── accounts
    │       ├── __init__.py
    │       ├── admin.py
    │       ├── apps.py
    │       ├── features
    │       │   ├── accounts.feature
    │       │   └── accounts_steps.py
    │       ├── migrations
    │       │   └── __init__.py
    │       ├── models.py
    │       ├── tests.py
    │       └── views.py

I was trying to run harvest with this setup but encounter this error and this remains when I write features file but no step definitions. I assumed that lettuce would discover the feature files but warn that the steps have not been defined.


 File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/mathewtrivett/.virtualenvs/unible/lib/python3.6/site-packages/lettuce/__init__.py", line 179
    print "Error loading step definitions:\n", e

SyntaxError: Missing parentheses in call to 'print'. Did you mean print(print "Error loading step definitions:\n", e)?``` 

This looks like a Python2 / 3 error in the __init__ file?
mariaae commented 6 years ago

@mathewtrivett hi! did you find a solution for this? I have the same issue :(

mathewtrivett commented 6 years ago

I'm not sure I ever found a solution but it is a compatibility issue between Python2 and Python3. One way to handle it is to only run your project with Python2 but that's likely a terrible idea if all the other modules you are using are built for python3.

Alternatively use another test framework. You won't get that BDD flavour but pytest is really great and simple to learn, results in pretty decent and clean code. Django generally has a pretty good test suite built off unittest.

michelts commented 6 years ago

I think there is an alternative if you want BDD with pytest:

https://github.com/pytest-dev/pytest-bdd

mariaae commented 6 years ago

@mathewtrivett Thank you for taking the time to answer back!

@michelts good to know! I will have a look at it :)

michelts commented 6 years ago

@mariaae if you didn't try Aloe and Aloe django as lettuce replacements, I recommend you do it.

Migrate from lettuce to aloe was pretty simple and it supports py3.

sgpy commented 5 years ago

@mariaae @mathewtrivett @michelts if you have time (and interested) in lettuce fork which support py27 & py37 git it a try. Just trying to get some feedback from community on Python 3 support