scott-griffiths / bitstring

A Python module to help you manage your bits
https://bitstring.readthedocs.io/en/stable/index.html
MIT License
404 stars 68 forks source link

Run `python -m unittest discover -s test` from root. #233

Closed tjni closed 2 years ago

tjni commented 2 years ago

The nixpkgs package manager builds many Python projects and expects that projects using unittest can run the unittest command from the root dir.

The only changes that are needed to do this is to use absolute paths for files in tests relative to the current test file's path.

I hope that this is not too burdensome on maintenance for this project.

FRidh commented 2 years ago

It is quite strange to have an __init__.py in a tests folder. Loading assets with absolute paths is I think a good idea.

tjni commented 2 years ago

It is quite strange to have an __init__.py in a tests folder. Loading assets with absolute paths is I think a good idea.

Removed the __init__.py. The command to run now from the root is python -m unittest discover -s test.

winterqt commented 2 years ago

It is quite strange to have an __init__.py in a tests folder.

I see quite a lot of projects that do it -- and it's how unittest's discovery finds the tests without having to specify the paths. Why is it strange, in your opinion?

scott-griffiths commented 2 years ago

Hi, thanks for the diff. I agree that it would be preferable to run the tests from root rather than the test directory, and I see no problem with an extra __init__.py file. I'm currently preparing a 4.0 release so I'll merge the change into that branch. Cheers.

scott-griffiths commented 2 years ago

Changed my mind and created a stable branch to do what main was previously doing, so can now merge to main directly!

tjni commented 2 years ago

Thank you! I'll add the __init__.py I removed (in an iteration based on earlier feedback) in a new PR that you can choose to merge or not at your preference.