Skip to content

Commit 349afbb

Browse files
committed
Stop installing tests
1 parent c996dd6 commit 349afbb

25 files changed

+63
-92
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ PYTHON ?= python3
33
all: check
44

55
check:
6-
$(PYTHON) -m testtools.run fixtures.test_suite
6+
$(PYTHON) -m testtools.run tests.test_suite
77

88
clean:
99
find . -name '*.pyc' -print0 | xargs -0 rm -f
1010

11-
TAGS: fixtures/*.py fixtures/tests/*.py
12-
ctags -e -R fixtures/
11+
TAGS: fixtures/*.py tests/*.py
12+
ctags -e -R fixtures/ tests/
1313

14-
tags: fixtures/*.py fixtures/tests/*.py
15-
ctags -R fixtures/
14+
tags: fixtures/*.py tests/*.py
15+
ctags -R fixtures/ tests/
1616

1717
.PHONY: all check clean

fixtures/__init__.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
Most users will want to look at TestWithFixtures and Fixture, to start with.
2626
"""
2727

28-
from typing import Any
29-
import unittest
30-
3128
from fixtures._version import __version__
3229

3330
__all__ = [
@@ -101,16 +98,3 @@
10198
WarningsFilter,
10299
)
103100
from fixtures.testcase import TestWithFixtures # noqa: E402
104-
105-
106-
def test_suite() -> unittest.TestSuite:
107-
import fixtures.tests # noqa: F401
108-
109-
return fixtures.tests.test_suite()
110-
111-
112-
def load_tests(
113-
loader: unittest.TestLoader, standard_tests: unittest.TestSuite, pattern: Any
114-
) -> unittest.TestSuite:
115-
standard_tests.addTests(loader.loadTestsFromNames(["fixtures.tests"]))
116-
return standard_tests

fixtures/_fixtures/streams.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def _setUp(self) -> None:
5959
write_stream, read_stream = self._stream_factory()
6060
self.stream = write_stream
6161
self.addDetail(
62-
self._detail_name, content_from_stream(read_stream, seek_offset=0)
62+
self._detail_name,
63+
content_from_stream(read_stream, seek_offset=0), # type: ignore[no-untyped-call]
6364
)
6465

6566

fixtures/fixture.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
Tuple,
3636
TypeVar,
3737
TYPE_CHECKING,
38+
Union,
3839
)
3940

4041
from fixtures.callmany import (
@@ -51,9 +52,11 @@
5152

5253
MultipleExceptions = fixtures.callmany.MultipleExceptions # type: ignore[attr-defined]
5354

54-
55+
gather_details: Union[Callable[[Dict[str, Any], Dict[str, Any]], None], None]
5556
try:
56-
from testtools.testcase import gather_details
57+
from testtools.testcase import gather_details as _gather_details
58+
59+
gather_details = _gather_details
5760
except ImportError:
5861
gather_details = None
5962

fixtures/testcase.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from fixtures.fixture import Fixture
2424
import fixtures.fixture
2525

26-
gather_details = fixtures.fixture.gather_details # type: ignore[attr-defined]
26+
gather_details = fixtures.fixture.gather_details
2727

2828
T = TypeVar("T", bound=Fixture)
2929

@@ -52,15 +52,23 @@ def useFixture(self, fixture: T) -> T:
5252
try:
5353
fixture.setUp()
5454
except:
55-
if use_details:
55+
if gather_details is not None and use_details:
5656
# Capture the details now, in case the fixture goes away.
57-
gather_details(fixture.getDetails(), self.getDetails()) # type: ignore[attr-defined]
57+
get_details = getattr(self, "getDetails", None)
58+
if get_details is not None:
59+
gather_details(fixture.getDetails(), get_details())
5860
raise
5961
else:
6062
self.addCleanup(fixture.cleanUp)
61-
if use_details:
63+
if gather_details is not None and use_details:
6264
# Capture the details from the fixture during test teardown;
6365
# this will evaluate the details before tearing down the
6466
# fixture.
65-
self.addCleanup(gather_details, fixture, self)
67+
def cleanup_details() -> None:
68+
if gather_details is not None:
69+
get_details = getattr(self, "getDetails", None)
70+
if get_details is not None:
71+
gather_details(fixture.getDetails(), get_details())
72+
73+
self.addCleanup(cleanup_details)
6674
return fixture

pyproject.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,3 @@ warn_unused_ignores = true
7474
warn_no_return = true
7575
warn_unreachable = true
7676
strict_equality = true
77-
78-
# Disable strict checking for tests
79-
[[tool.mypy.overrides]]
80-
module = "fixtures.tests.*"
81-
ignore_errors = true
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def load_tests(
3434
"fixture",
3535
"testcase",
3636
]
37-
prefix = "fixtures.tests.test_"
37+
prefix = "tests.test_"
3838
test_mod_names = [prefix + test_module for test_module in test_modules]
3939
standard_tests.addTests(loader.loadTestsFromNames(test_mod_names))
40-
standard_tests.addTests(loader.loadTestsFromName("fixtures.tests._fixtures"))
40+
standard_tests.addTests(loader.loadTestsFromName("tests._fixtures"))
4141
doctest.set_unittest_reportflags(doctest.REPORT_ONLY_FIRST_FAILURE)
42-
standard_tests.addTest(doctest.DocFileSuite("../../README.rst"))
42+
standard_tests.addTest(doctest.DocFileSuite("../README.rst"))
4343
return standard_tests
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def load_tests(loader, standard_tests, pattern):
2222
for path in os.listdir(os.path.dirname(__file__))
2323
if path.startswith("test_")
2424
]
25-
prefix = "fixtures.tests._fixtures."
25+
prefix = "tests._fixtures."
2626
test_mod_names = [prefix + test_module for test_module in test_modules]
2727
standard_tests.addTests(loader.loadTestsFromNames(test_mod_names))
2828
return standard_tests

0 commit comments

Comments
 (0)