Skip to content

Commit bb38141

Browse files
Rewrite wheel_resolver tests to run under unittest
The wheel_resolver tests run under pytest, but don't actually rely on any pytest-specific functionality - rewrite them so they run under unittest instead.
1 parent 93ec6d2 commit bb38141

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

tools/wheel_resolver/BUILD

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ python_test(
3636
"__init___test.py",
3737
"wheel_test.py",
3838
],
39-
test_runner="pytest",
4039
deps=[
4140
":wheel",
42-
"//third_party/python:pytest",
4341
],
4442
)

tools/wheel_resolver/__init___test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import click.testing
2+
import unittest
23
import unittest.mock
34
import tools.wheel_resolver as sut
45

56

6-
class TestMain:
7+
class TestMain(unittest.TestCase):
78
def test_help(self) -> None:
89
runner = click.testing.CliRunner()
910
result = runner.invoke(cli=sut.main, args=["--help"])

tools/wheel_resolver/wheel_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import pytest
21
import tools.wheel_resolver.wheel as sut
32
import collections
43
import typing
4+
import unittest
55
import unittest.mock
66
import distlib.locators
77
import distlib.database
@@ -13,7 +13,7 @@
1313
)
1414

1515

16-
class TestUrl:
16+
class TestUrl(unittest.TestCase):
1717
def _mock_locator(
1818
self,
1919
*,
@@ -36,7 +36,7 @@ def _mock_locator(
3636
)
3737

3838
def test_no_distribution(self) -> None:
39-
with pytest.raises(sut.DistributionNotFoundError):
39+
with self.assertRaises(sut.DistributionNotFoundError):
4040
sut.url(
4141
package_name="",
4242
package_version=None,
@@ -45,15 +45,15 @@ def test_no_distribution(self) -> None:
4545
)
4646

4747
def test_no_compatible_urls(self) -> None:
48-
with pytest.raises(sut.CompatibleUrlNotFoundError):
48+
with self.assertRaises(sut.CompatibleUrlNotFoundError):
4949
sut.url(
5050
package_name="",
5151
package_version=None,
5252
tags=[],
5353
locator=self._mock_locator(),
5454
)
5555

56-
@pytest.mark.skip("caplog doesn't capture logging")
56+
@unittest.skip("caplog doesn't capture logging")
5757
def test_warns_multiple_compatible_urls(self, caplog) -> None:
5858
with caplog.at_level(logging.WARNING, logger=sut.__name__):
5959
sut.url(
@@ -73,7 +73,7 @@ def test_warns_multiple_compatible_urls(self, caplog) -> None:
7373
assert len(caplog.records) > 0
7474
assert any(x.level == logging.WARNING for x in caplog.records)
7575

76-
@pytest.mark.skip(
76+
@unittest.skip(
7777
"ordering and selection is unclear; this test case should be updated if we have a preference for a specific URL when collissions happen."
7878
)
7979
def test_preferred_url(self) -> None:

0 commit comments

Comments
 (0)