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

test: do not assume parent directory name #30

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import unittest
import logging
import json
import os.path


from django.core.handlers.wsgi import WSGIRequest
Expand Down Expand Up @@ -319,7 +320,7 @@ def test_logger_name_is_test(self):
def test_path_name_is_test(self):
logger.error('An error has occured')
json_record = json.loads(log_buffer.getvalue())
self.assertIn('json-log-formatter/tests.py', json_record['pathname'])
self.assertIn(os.path.basename(os.path.abspath('.')) + '/tests.py', json_record['pathname'])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please tell when does this test break and how can it be reproduced?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just by not having the name of the root directory of the project to be "json-log-formatter".

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no plans to rename the directory name, so I am not sure how it can help.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, i made a debian package python3-json-log-formatter
The source of that package, when being built in debian infrastructure, is put in some directory like
python-json-log-formatter_0.5.2/
Since the tests are run from that directory, one of them fail.
The change I propose here let the test work independently of the name of the parent directory where the test is run.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, that makes sense.


def test_process_name_is_MainProcess(self):
logger.error('An error has occured')
Expand Down