forked from conda/constructor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removes the usage of
conda._vendor.toolz
from constructor (conda#525)
* Removes the usage of toolz from conda This commit attempts to replace the usage of toolz in the main conda project. In an upcoming conda release, this will be completely removed. Co-authored-by: Ken Odegard <[email protected]>
- Loading branch information
1 parent
5799a06
commit 10fe8e4
Showing
3 changed files
with
83 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from __future__ import annotations | ||
|
||
from contextlib import nullcontext | ||
|
||
import pytest | ||
|
||
from constructor.fcp import check_duplicates, exclude_packages | ||
|
||
|
||
class GenericObject: | ||
"""We use this for testing the check_duplicates function""" | ||
def __init__(self, name): | ||
self.name = name | ||
self.fn = 'filename.txt' | ||
|
||
def __eq__(self, other): | ||
return self.name == other.name | ||
|
||
|
||
@pytest.mark.parametrize('values,expected_fails', ( | ||
( | ||
(GenericObject('NameOne'), GenericObject('NameTwo'), GenericObject('NameTwo')), 1 | ||
), | ||
( | ||
(GenericObject('NameOne'), GenericObject('NameTwo')), 0 | ||
), | ||
( | ||
(GenericObject('NameOne'), GenericObject('NameTwo'), GenericObject('NameThree')), 0 | ||
), | ||
)) | ||
def test_check_duplicates(values: tuple[..., GenericObject], expected_fails: int): | ||
if expected_fails: | ||
context = pytest.raises(SystemExit) | ||
else: | ||
context = nullcontext() | ||
|
||
with context: | ||
check_duplicates(values) | ||
|
||
|
||
@pytest.mark.parametrize('values,expected_value', ( | ||
( | ||
( | ||
(GenericObject('NameOne'), GenericObject('NameTwo'), GenericObject('NameThree')), | ||
('NameThree',) | ||
), | ||
[GenericObject('NameOne'), GenericObject('NameTwo')] | ||
), | ||
( | ||
( | ||
(GenericObject('NameOne'), GenericObject('NameTwo'), GenericObject('NameThree')), | ||
('Not in list',) | ||
), | ||
False | ||
), | ||
)) | ||
def test_exclude_packages(values: tuple[..., GenericObject], expected_value): | ||
if expected_value is False: | ||
context = pytest.raises(SystemExit) | ||
else: | ||
context = nullcontext() | ||
|
||
with context: | ||
packages = exclude_packages(*values) | ||
assert packages == expected_value |