1

So I have an integration test that tests multiple components of my application together, the whole end-to-end test. I need to pipe it to Django shell in order to be able to access models etc. But I also need to pass a parameter to the script. This is what I am doing:

venv/bin/python src/manage.py shell < src/integration_tests/endtoend.py

But what I want to do is:

venv/bin/python src/manage.py shell < src/integration_tests/endtoend.py -o 2

If I do that, it throws an exception though:

Usage: src/manage.py shell [options] 

Runs a Python interactive interpreter. Tries to use IPython, if it's available.

src/manage.py: error: no such option: -o

How should I do this?

3
  • Just curious to why you didn't write it as a standard test? Commented Feb 21, 2013 at 10:44
  • @Lennart Regebro Because it's integration test. There should be a clear separation between unit tests, integration tests, BDD tests etc. Unit tests should be completely isolated and only test single units of your application. Also, my integration test is calling a third service API and parsing it's response so it cannot be run together with unit tests. When I run ./manage.py test myapp I don't want to make any connection outside of my box so I can run the tests even on box that is not connected to the internet. Commented Feb 21, 2013 at 14:36
  • That they should be separated doesn't mean that they shouldn't be written using unittest. :-) Put them in a separate app and they'll be run separately. Commented Feb 21, 2013 at 16:59

1 Answer 1

1

You need to write a Python script that takes parameters and outputs the script so you can pipe it to manage.py.

python src/integration_tests/endtoend.py -o 2 | python src/manage.py shell

I'm pretty sure I wouldn't do that, but that's what you need to do to pass in command line parameters.

Other options are environment variables and configuration files.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.