Repository: nicoddemus/pytest-drop-dup-tests (language: python)

Issue:
Files explicitly given in the command line not being deduplicated
This is simply not working for me. Any ideas why/what to try?
```
$PYTHONPATH=svr pytest test/ test/run_test.py -v
======================================================== test session starts =========================================================
platform linux -- Python 3.6.8, pytest-5.4.2, py-1.8.1, pluggy-0.13.1 -- /mnt/c/Users/legaul/ET/helper-scripts/src/tools-listing/test/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /mnt/c/Users/legaul/ET/helper-scripts/src/tools-listing/test, inifile: pytest.ini
plugins: drop-dup-tests-0.2.0
collected 3 items

test/run_test.py::LoadYamlTest::test_success PASSED                                                                            [ 33%]
test/yaml_test.py::test_yaml PASSED                                                                                            [ 66%]
test/run_test.py::LoadYamlTest::test_success PASSED                                                                            [ 66%]

========================================================= 3 passed in 0.67s ==========================================================


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index ee59eb7..81ea766 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -9,7 +9,18 @@ jobs:
     strategy:
       max-parallel: 4
       matrix:
-        python-version: [2.7, 3.8]
+        tox-env: ["py27", "py36", "py37", "py38", "linting"]
+        include:
+          - tox-env: "py27"
+            python-version: "2.7"
+          - tox-env: "py36"
+            python-version: "3.6"
+          - tox-env: "py37"
+            python-version: "3.7"
+          - tox-env: "py38"
+            python-version: "3.8"
+          - tox-env: "linting"
+            python-version: "3.8"
 
     steps:
     - uses: actions/checkout@v1
@@ -20,17 +31,17 @@ jobs:
     - name: Dependencies
       run: |
         python -m pip install --upgrade pip
-        pip install tox    
+        pip install tox
     - name: Test
       run: |
-        tox -e py
+        tox -e ${{ matrix.tox-env }}
 
   deploy:
     if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
 
     runs-on: ubuntu-latest
     needs: build
-    
+
     steps:
     - uses: actions/checkout@v1
     - name: Set up Python
@@ -44,7 +55,7 @@ jobs:
     - name: Build package
       run: |
         python setup.py sdist bdist_wheel
-    - name: Publish package to PyPI      
+    - name: Publish package to PyPI
       uses: pypa/gh-action-pypi-publish@master
       with:
         user: __token__
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..04daf66
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,19 @@
+repos:
+  - repo: https://github.com/ambv/black
+    rev: 19.10b0
+    hooks:
+      - id: black
+        args: [--safe, --quiet]
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v3.1.0
+    hooks:
+      - id: trailing-whitespace
+      - id: end-of-file-fixer
+  - repo: local
+    hooks:
+      - id: rst
+        name: rst
+        entry: rst-lint --encoding utf-8
+        files: ^(CHANGELOG.rst|README.rst)$
+        language: python
+        additional_dependencies: [pygments, restructuredtext_lint]
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index d88e184..c7bb5db 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,3 +1,10 @@
+0.3.0
+=====
+
+- Files passed on the command-line are now deduplicated as well (`#5`_).
+
+.. _#5: https://github.com/nicoddemus/pytest-drop-dup-tests/issues/5
+
 0.2.0
 =====
 
diff --git a/LICENSE b/LICENSE
index 69f5241..5fad4fc 100644
--- a/LICENSE
+++ b/LICENSE
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
\ No newline at end of file
+THE SOFTWARE.
diff --git a/README.rst b/README.rst
index f05167b..7895fbb 100644
--- a/README.rst
+++ b/README.rst
@@ -32,13 +32,6 @@ This plugin was born from the discussion taken in `#1187`_.
 This `Pytest`_ plugin was generated with `Cookiecutter`_ along with `@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template.
 
 
-Requirements
-------------
-
-* Python 2.7 or 3.5+
-* pytest >= 2.7
-
-
 Installation
 ------------
 
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..2a9acf1
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,2 @@
+[bdist_wheel]
+universal = 1
diff --git a/setup.py b/setup.py
index aaecd05..07a7af2 100644
--- a/setup.py
+++ b/setup.py
@@ -8,44 +8,38 @@
 
 def read(fname):
     file_path = os.path.join(os.path.dirname(__file__), fname)
-    return codecs.open(file_path, encoding='utf-8').read()
+    return codecs.open(file_path, encoding="utf-8").read()
 
 
 setup(
-    name='pytest-drop-dup-tests',
-    version='0.1.0',
-    author='Bruno Oliveira',
-    author_email='nicoddemus@gmail.com',
-    maintainer='Bruno Oliveira',
-    maintainer_email='nicoddemus@gmail.com',
-    license='MIT',
-    url='https://github.com/nicoddemus/pytest-drop-dup-tests',
-    description='A Pytest plugin to drop duplicated tests during collection',
-    long_description=read('README.rst'),
-    py_modules=['pytest_drop_dup_tests'],
-    setup_requires='setuptools_scm',
+    name="pytest-drop-dup-tests",
+    author="Bruno Oliveira",
+    author_email="nicoddemus@gmail.com",
+    maintainer="Bruno Oliveira",
+    maintainer_email="nicoddemus@gmail.com",
+    license="MIT",
+    url="https://github.com/nicoddemus/pytest-drop-dup-tests",
+    description="A Pytest plugin to drop duplicated tests during collection",
+    long_description=read("README.rst"),
+    py_modules=["pytest_drop_dup_tests"],
+    setup_requires="setuptools_scm",
     use_scm_version=True,
-    install_requires=['pytest>=2.7'],
+    install_requires=["pytest>=2.7"],
     classifiers=[
-        'Development Status :: 4 - Beta',
-        'Framework :: Pytest',
-        'Intended Audience :: Developers',
-        'Topic :: Software Development :: Testing',
-        'Programming Language :: Python',
-        'Programming Language :: Python :: 2',
-        'Programming Language :: Python :: 2.7',
-        'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.3',
-        'Programming Language :: Python :: 3.4',
-        'Programming Language :: Python :: 3.5',
-        'Programming Language :: Python :: Implementation :: CPython',
-        'Programming Language :: Python :: Implementation :: PyPy',
-        'Operating System :: OS Independent',
-        'License :: OSI Approved :: MIT License',
+        "Development Status :: 4 - Beta",
+        "Framework :: Pytest",
+        "Intended Audience :: Developers",
+        "Topic :: Software Development :: Testing",
+        "Programming Language :: Python",
+        "Programming Language :: Python :: 2",
+        "Programming Language :: Python :: 2.7",
+        "Programming Language :: Python :: 3",
+        "Programming Language :: Python :: 3.6",
+        "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8",
+        "Programming Language :: Python :: Implementation :: CPython",
+        "Operating System :: OS Independent",
+        "License :: OSI Approved :: MIT License",
     ],
-    entry_points={
-        'pytest11': [
-            'drop-dup-tests = pytest_drop_dup_tests',
-        ],
-    },
+    entry_points={"pytest11": ["drop-dup-tests = pytest_drop_dup_tests",],},
 )
diff --git a/tox.ini b/tox.ini
index 74bf75c..1ec99e1 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,10 @@
-# For more information about tox, see https://tox.readthedocs.org/en/latest/
 [tox]
-envlist = py27,py33,py34,py35,pypy
+envlist = py27,py36,py37,py38,linting
 
 [testenv]
-deps = pytest
-commands = py.test {posargs:tests}
+commands = pytest {posargs:tests}
+
+[testenv:linting]
+skip_install = True
+deps = pre-commit
+commands = pre-commit run --all-files --show-diff-on-failure


Test patch:
diff --git a/pytest_drop_dup_tests.py b/pytest_drop_dup_tests.py
index 0dad019..646ccb5 100644
--- a/pytest_drop_dup_tests.py
+++ b/pytest_drop_dup_tests.py
@@ -1,13 +1,26 @@
-
-
-_seen = set()
+_seen_paths = set()
 
 
 def pytest_ignore_collect(path, config):
-    if path.basename == '__init__.py':
+    if path.basename == "__init__.py":
         return None
-    if path in _seen:
+    if path in _seen_paths:
         return True
     else:
-        _seen.add(path)
+        _seen_paths.add(path)
         return None
+
+
+def pytest_collection_modifyitems(config, items):
+    seen_node_ids = set()
+    new_items = []
+    deselected_items = []
+    for item in items:
+        if item.nodeid not in seen_node_ids:
+            new_items.append(item)
+            seen_node_ids.add(item.nodeid)
+        else:
+            deselected_items.append(item)
+
+    items[:] = new_items
+    config.hook.pytest_deselected(items=deselected_items)
diff --git a/tests/conftest.py b/tests/conftest.py
index bc711e5..694d7d5 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,1 +1,1 @@
-pytest_plugins = 'pytester'
+pytest_plugins = "pytester"
diff --git a/tests/test_drop_dup_tests.py b/tests/test_drop_dup_tests.py
index 33128f4..dd7dd21 100644
--- a/tests/test_drop_dup_tests.py
+++ b/tests/test_drop_dup_tests.py
@@ -2,26 +2,55 @@
 
 
 def test_drop_duplicated_dir(testdir):
-    testdir.makepyfile("""
+    testdir.makepyfile(
+        """
         def test_foo():
             pass
-    """)
-    result = testdir.runpytest('.', '.')
-    result.stdout.fnmatch_lines([
-        '* 1 passed in *',
-    ])
+        """
+    )
+    result = testdir.runpytest(".", ".")
+    result.stdout.fnmatch_lines(
+        ["* 1 passed in *",]
+    )
     assert result.ret == 0
 
 
 def test_drop_duplicated_pkg(testdir):
-    testdir.makepyfile(**{
-        "pkg/__init__.py": "",
-        "pkg/test_foo.py": """
-        def test_foo():
-            pass
-    """})
-    result = testdir.runpytest('pkg', 'pkg')
-    result.stdout.fnmatch_lines([
-        '* 1 passed in *',
-    ])
+    testdir.makepyfile(
+        **{
+            "pkg/__init__.py": "",
+            "pkg/test_foo.py": """
+                def test_foo():
+                    pass
+            """,
+        }
+    )
+    result = testdir.runpytest("pkg", "pkg")
+    result.stdout.fnmatch_lines(
+        ["* 1 passed in *",]
+    )
+    assert result.ret == 0
+
+
+def test_drop_duplicated_files(testdir):
+    testdir.makepyfile(
+        **{
+            "tests/test_foo.py": """
+                def test_foo():
+                    pass
+            """,
+            "tests/test_bar.py": """
+                def test_bar():
+                    pass
+            """,
+        }
+    )
+    result = testdir.runpytest("tests", "tests/test_foo.py", "-v")
+    result.stdout.fnmatch_lines(
+        [
+            "tests/test_bar.py::test_bar *",
+            "tests/test_foo.py::test_foo *",
+            "* 2 passed, 1 deselected in *",
+        ]
+    )
     assert result.ret == 0