Sean Payne
Sean Payne

Reputation: 1961

Viewing Pytest output with Docker

I have a Pytest script I'd like to run on my flask models using Docker. I run my docker instance with

docker-compose up

I then attach to the instance

docker attach my-app-name-here

And then I run my tests

docker exec -it $APP_ID python tests.py

There are a bunch of assert statements in my test file but I can't get any output to the attached container. How can I see my test output in my local terminal/command-line?

Thank you

My test code (part of it for example)

def test_scores_model():
    scores = Scores(1, "7b25a87c-d2c8-49e3-83ac-88dcc1d94902", 4.5, 5.5, 3.5, 2.5, 4.5, 3.5, 0.5, 2.5, 3.5, 1.5, None)
    assert scores.scores_id == 1
    assert scores.session_id == "7b25a87c-d2c8-49e3-83ac-88dcc1d94902"
    assert scores.security == 4.5

Upvotes: 2

Views: 1300

Answers (1)

Sean Payne
Sean Payne

Reputation: 1961

I needed to run the command

docker exec -it $APP_ID pytest tests.py

Note that python has been replaced with pytest.

Upvotes: 1

Related Questions