-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Quotation marks in pytest command collects duplicate tests #7012
Comments
At first glance i believe '' is considereas '.' Unfortunately i don't know if i can verify this weekend |
Yeah, I'd bet that we're using |
Will investigate this one if thats ok |
from what I gather we care not about file paths explicitly, regardless of |
Right now I have no idea, currently I'm also stepped away from the Project |
I reproduced the behaviour and applied the changes @symonk suggested. I went one step further and added another test to show that duplicates are a desired effect: def test_collection_duplicates_if_specified_twice(testdir):
foo = testdir.makepyfile(foo="""
def test_duplicate_if_specified():
pass
"""
)
result = testdir.runpytest("./foo.py", ".", "--collect-only")
result.stdout.fnmatch_lines(
[
"collected 2 items",
"<Module foo.py>",
" <Function test_duplicate_if_specified>",
"<Module foo.py>",
" <Function test_duplicate_if_specified>",
]
) I had a look at the @bluetech I think I would suggest to reopen the PR from @symonk (perhaps adding the test of this comment) and accept it. As an alternative I can open a PR if reopening is no option. What are your thoughts on this? |
@DahlitzFlorian, in #7081 (comment) I wrote
I don't remember all of the details, but have you looked at this? |
I read your comment and had a look at it. I identified the https://github.com/pytest-dev/pytest/blob/master/src/_pytest/nodes.py#L540 However, I was not able to modify it in a way that let the tests cases pass and won't break other test cases. |
From the link, it seems to currently rely on |
The issue that I see is that the empty string ( |
@DahlitzFlorian So I think there two issues here, let me try to untangle them for myself at least: Problem 1: $ ls ''
ls: cannot access '': No such file or directory I think pytest should follow the common behavior and not treat the empty string as the current directory. Problem 2: The duplicate detection (
both run the tests in This may be intentional, I'm not sure. |
@bluetech Thanks for these insights. Indeed, it seems like |
my 2c is that |
Yeah, for the first problem I agree. Looking at this, the conversion happens here: Line 616 in 70b5bdf
So I think this function ( |
Forgot to mention that I agree with @asottile that it should be an error, and not silently skipped. |
Sounds good. Today or tomorrow I will submit a PR addressing it. |
My first attempt was to check in However, it turned out that this would make five of our tests fail as they use Line 610 in 70b5bdf
https://github.com/pytest-dev/pytest/blob/master/testing/logging/test_reporting.py#L870 |
In the case of this particular test, I'd change the |
I guess, we need to check whether it was |
a detailed description of the bug or suggestion
Extra single or double quotation marks ('' or "") in pytest command results in duplicate tests in pytest run
pip list
The text was updated successfully, but these errors were encountered: