Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #201 from milind-shakya-sp/sp
Browse files Browse the repository at this point in the history
Add exclude parameters to be passed in.
  • Loading branch information
brettcannon committed May 6, 2019
2 parents cc28a61 + c60c64a commit 8b7326d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion caniusepython3/__main__.py
Expand Up @@ -18,7 +18,6 @@
from caniusepython3 import dependencies
from caniusepython3 import projects as projects_

import distlib.metadata
import packaging.utils

import argparse
Expand All @@ -45,6 +44,8 @@ def projects_from_cli(args):
help='name(s) of projects to test for Python 3 support')
parser.add_argument('--verbose', '-v', action='store_true',
help='verbose output (e.g. list compatibility overrides)')
parser.add_argument('--exclude', '-e', action='append', default=[],
help='Ignore list')
parsed = parser.parse_args(args)

if not (parsed.requirements or parsed.metadata or parsed.projects):
Expand All @@ -61,6 +62,7 @@ def projects_from_cli(args):
projects.extend(projects_.projects_from_metadata(metadata))
projects.extend(map(packaging.utils.canonicalize_name, parsed.projects))

projects = {i for i in projects if i not in parsed.exclude}
return projects


Expand Down
12 changes: 12 additions & 0 deletions caniusepython3/test/test_cli.py
Expand Up @@ -66,6 +66,7 @@
Requires-Dist: baz
"""


class CLITests(unittest.TestCase):

expected_requirements = frozenset(['foo-project', 'fizzy', 'pickything',
Expand Down Expand Up @@ -118,6 +119,17 @@ def test_cli_for_requirements(self):
got = ciu_main.projects_from_cli(args)
self.assertEqual(set(got), self.expected_requirements)

def test_excluding_requirements(self):
with tempfile.NamedTemporaryFile('w') as file:
file.write(EXAMPLE_REQUIREMENTS)
file.flush()
args = ['--requirements', file.name, '--exclude', 'pickything']
got = ciu_main.projects_from_cli(args)
expected_requirements = set(self.expected_requirements)
expected_requirements.remove('pickything')
self.assertNotIn('pickything', set(got))
self.assertEqual(set(got), expected_requirements)

def test_cli_for_metadata(self):
with tempfile.NamedTemporaryFile('w') as file:
file.write(EXAMPLE_METADATA)
Expand Down

0 comments on commit 8b7326d

Please sign in to comment.