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

How to not write to log but append to the log file. #16

Closed
boonyao1122 opened this issue Jun 6, 2018 · 2 comments
Closed

How to not write to log but append to the log file. #16

boonyao1122 opened this issue Jun 6, 2018 · 2 comments
Labels

Comments

@boonyao1122
Copy link

boonyao1122 commented Jun 6, 2018

Hi, i am new to pytest and also python. I am trying out the example you gave.
Example which i following, here

During run my test, logs are always write to my generated log files but not append to end of file. Any how to change to append instead of writing?

@boonyao1122 boonyao1122 changed the title Contents are not append to the logfile when run second time. How to not write to log but append to the log file. Jun 6, 2018
@aurzenligl
Copy link
Owner

aurzenligl commented Jun 18, 2018

Hello @boonyao1122, sorry for keeping you waiting. Files are written to a new directory, which is by default a pytest session's tempdir:
https://docs.pytest.org/en/latest/tmpdir.html

Each pytest run (i.e. "session") logs are written anew to a different dir:

$ pytest > /dev/null ; ll logs
lrwxrwxrwx 1 aurzenligl aurzenligl 39 Jun 18 02:39 logs -> /tmp/pytest-of-aurzenligl/pytest-3/logs
$ pytest > /dev/null ; ll logs
lrwxrwxrwx 1 aurzenligl aurzenligl 39 Jun 18 02:39 logs -> /tmp/pytest-of-aurzenligl/pytest-4/logs

If user chooses own dir, which is the same during each run, files will get overwritten. It doesn't seem to make sense to append to them, as output would get mixed in a way making it difficult to figure out which run given log line comes from.

Does that answer the question?

@aurzenligl
Copy link
Owner

Closed due to inactivity.

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

No branches or pull requests

2 participants