Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialisation error in Django project #557

Open
mathewtrivett opened this issue Dec 21, 2017 · 6 comments
Open

Initialisation error in Django project #557

mathewtrivett opened this issue Dec 21, 2017 · 6 comments

Comments

@mathewtrivett
Copy link

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?
@mathewtrivett mathewtrivett changed the title initialisation error Initialisation error in Django project Dec 21, 2017
@mariaae
Copy link

mariaae commented Jun 8, 2018

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

@mathewtrivett
Copy link
Author

mathewtrivett commented Jun 10, 2018

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
Copy link
Contributor

michelts commented Jun 13, 2018

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

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

@mariaae
Copy link

mariaae commented Jun 13, 2018

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

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

@michelts
Copy link
Contributor

@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
Copy link

sgpy commented Feb 11, 2019

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants