Feature/5 collect only actual test matter#9
Conversation
I'm not sure if I get it. In this case, we are removing the tests that were collected already. So, we need to know if the collected tests are inside of that folder or not. I opened a PR few days ago to change this approach, since it was taking longer than needed. In this PR we are indicating the folders and files that pytest should collect (and execute). See #8.
I'm afraid not. Since this is from specifically from your development environment, I would advise you adding it to a global .gitignore. Thanks for contributing! |
anapaulagomes
left a comment
There was a problem hiding this comment.
That's an essential part of this plugin. Thanks for bringing it!
| return | ||
|
|
||
| picked_files, picked_folders = _affected_tests() | ||
| test_files = config._getini('python_files') |
There was a problem hiding this comment.
Maybe we should make it more implicit like test_file_convention. When I read test_files sounds like the tests files instead of the convention adopted.
| """ | ||
| raw_output = _get_git_status() | ||
|
|
||
| re_list = [item.replace('.', '\.').replace('*', '.*') |
There was a problem hiding this comment.
Since we're using Black to enforce the code style, you should use double quotes in this line. I added Lambda Lint to help us with it.
| if file_or_folder.endswith("/"): | ||
| if file_or_folder.endswith("/"): | ||
| path = Path(file_or_folder) | ||
| if any([part.startswith("test") for part in path.parts]): |
There was a problem hiding this comment.
In this case, I don't think we need to check if the folder has test on it. For instance, if you add a new folder called api and inside of it you have other folders or test_bla.py, we are going to miss it. git status will show just api/. IMO, for this case, we must rely on pytest to check the files.
There was a problem hiding this comment.
Couldn't we check inside the new folder for test files? This is what I meant by getting rid of folder checking and just checking the flles.
Where $ git status --short will return:
M project/accounts/tests/test_api.py
?? newapp/
$ git status --short --untracked-files' will return:
M project/accounts/tests/test_api.py
?? newapp/__init__.py
?? newapp/admin.py
?? newapp/apps.py
?? newapp/migrations/__init__.py
?? newapp/models.py
?? newapp/tests/test_views.py
?? newapp/views.py
So that we can just check by the file names. See: https://git-scm.com/docs/git-status/1.8.1#git-status---untracked-filesltmodegt
Oddly enough, whenever an untracked folder is added, git status immediately shows the individual files.
There was a problem hiding this comment.
Couldn't we check inside the new folder for test files? This is what I meant by getting rid of folder checking and just checking the flles.
Where $ git status --short will return:
M project/accounts/tests/test_api.py
?? newapp/
$ git status --short --untracked-files' will return:
M project/accounts/tests/test_api.py
?? newapp/__init__.py
?? newapp/admin.py
?? newapp/apps.py
?? newapp/migrations/__init__.py
?? newapp/models.py
?? newapp/tests/test_views.py
?? newapp/views.py
So that we can just check by the file names. see: https://git-scm.com/docs/git-status/1.8.1#git-status---untracked-filesltmodegt
Oddly enough, whenever an untracked folder is added, git status immediately shows the individual files.
Perhaps we address this in a separate ticket? For the meantime, I've changed it as requested.
| + b" U tests/test_pytest_picked.py\n" | ||
| + b"?? random/tests/" | ||
| + b"?? random/tests/\n" | ||
| + b" M intestine.py\n" |
|
I've made the requested changes. Thanks again for explaining the project and answering all my questions. Let me know if you have any more feedback. |
|
I'm glad we're supporting |
Hi,
Thanks for the tip on finding the parsing string. From there, the problem just unravelled.
I have very mixed feelings on folder discovery. I'm not at all sure it is practical if the module finds all the test files. Is there a particular philosophy on it?
Also, is there any chance to add vim stuff to
.gitignore? The swap files keep trying to get committed.Thanks.