type-assert 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {type_assert-0.2.0 → type_assert-0.2.1}/PKG-INFO +1 -1
  2. {type_assert-0.2.0 → type_assert-0.2.1}/tests/test_plugin.py +14 -0
  3. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/_version.py +3 -3
  4. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/plugin.py +22 -2
  5. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert.egg-info/PKG-INFO +1 -1
  6. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert.egg-info/scm_version.json +2 -2
  7. {type_assert-0.2.0 → type_assert-0.2.1}/.github/dependabot.yml +0 -0
  8. {type_assert-0.2.0 → type_assert-0.2.1}/.github/release.yml +0 -0
  9. {type_assert-0.2.0 → type_assert-0.2.1}/.github/workflows/ci.yml +0 -0
  10. {type_assert-0.2.0 → type_assert-0.2.1}/.gitignore +0 -0
  11. {type_assert-0.2.0 → type_assert-0.2.1}/.pre-commit-config.yaml +0 -0
  12. {type_assert-0.2.0 → type_assert-0.2.1}/LICENSE +0 -0
  13. {type_assert-0.2.0 → type_assert-0.2.1}/README.md +0 -0
  14. {type_assert-0.2.0 → type_assert-0.2.1}/pyproject.toml +0 -0
  15. {type_assert-0.2.0 → type_assert-0.2.1}/setup.cfg +0 -0
  16. {type_assert-0.2.0 → type_assert-0.2.1}/tests/conftest.py +0 -0
  17. {type_assert-0.2.0 → type_assert-0.2.1}/tests/test_assertions.py +0 -0
  18. {type_assert-0.2.0 → type_assert-0.2.1}/tests/test_cases.py +0 -0
  19. {type_assert-0.2.0 → type_assert-0.2.1}/tests/test_checkers.py +0 -0
  20. {type_assert-0.2.0 → type_assert-0.2.1}/tools/check_without_checker.py +0 -0
  21. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/__init__.py +0 -0
  22. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/_assertions.py +0 -0
  23. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/_cases.py +0 -0
  24. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/_checkers/__init__.py +0 -0
  25. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/_checkers/_base.py +0 -0
  26. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/_checkers/_mypy.py +0 -0
  27. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/_checkers/_pyrefly.py +0 -0
  28. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/_checkers/_pyright.py +0 -0
  29. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/_exact.py +0 -0
  30. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert/py.typed +0 -0
  31. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert.egg-info/SOURCES.txt +0 -0
  32. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert.egg-info/dependency_links.txt +0 -0
  33. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert.egg-info/entry_points.txt +0 -0
  34. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert.egg-info/requires.txt +0 -0
  35. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert.egg-info/scm_file_list.json +0 -0
  36. {type_assert-0.2.0 → type_assert-0.2.1}/type_assert.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: type-assert
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: pytest plugin that checks a value static type and its runtime type in one assertion
5
5
  Author: user27182
6
6
  License-Expression: MIT
@@ -164,6 +164,20 @@ def test_a_quoted_type_only_a_checker_can_build_is_checked_statically(project, c
164
164
  result.stdout.fnmatch_lines(['*cannot be built at runtime*'])
165
165
 
166
166
 
167
+ def test_a_case_file_named_on_the_command_line_is_collected_once_as_cases(project):
168
+ # pytest collects an explicitly named `.py` file as a test module whatever its
169
+ # name; importing this one would run the quoted assertion at import and fail.
170
+ result = project(QUOTED_NEVER).runpytest('cases/sample.py', '-rs')
171
+ result.assert_outcomes(passed=2, skipped=1, errors=0)
172
+ result.stdout.fnmatch_lines(['*cannot be built at runtime*'])
173
+
174
+
175
+ def test_a_case_file_named_on_the_command_line_yields_the_same_tests(project):
176
+ result = project(CLEAN).runpytest('cases/sample.py', '--collect-only', '-q')
177
+ result.stdout.fnmatch_lines(['*::setup', '*len([[]1[]]) -> int [[]runtime[]]'])
178
+ assert result.stdout.str().count('[runtime]') == 2
179
+
180
+
167
181
  def test_a_quoted_type_the_runtime_can_build_is_held_to_by_both_halves(project):
168
182
  source = (
169
183
  'from type_assert import assert_types\n\n'
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.2.0'
22
- __version_tuple__ = version_tuple = (0, 2, 0)
21
+ __version__ = version = '0.2.1'
22
+ __version_tuple__ = version_tuple = (0, 2, 1)
23
23
 
24
- __commit_id__ = commit_id = 'gd0866227d'
24
+ __commit_id__ = commit_id = 'gc60ea7172'
@@ -85,14 +85,34 @@ def cases_dir(config: pytest.Config) -> Path | None:
85
85
  return (Path(config.rootpath) / configured).resolve()
86
86
 
87
87
 
88
+ def _is_case_file(file_path: Path, config: pytest.Config) -> bool:
89
+ """Tell whether `file_path` is a `.py` file in the configured cases directory."""
90
+ directory = cases_dir(config)
91
+ return directory is not None and file_path.suffix == '.py' and file_path.parent == directory
92
+
93
+
88
94
  def pytest_collect_file(file_path: Path, parent: pytest.Collector):
89
95
  """Collect a `.py` file in the configured cases directory as a case file."""
90
- directory = cases_dir(parent.config)
91
- if directory is None or file_path.suffix != '.py' or file_path.parent != directory:
96
+ # A path named on the command line reaches `pytest_pycollect_makemodule` below,
97
+ # which is where pytest's own Python collector would otherwise pick it up.
98
+ if not _is_case_file(file_path, parent.config) or parent.session.isinitpath(file_path):
92
99
  return None
93
100
  return CaseFileCollector.from_parent(parent, path=file_path)
94
101
 
95
102
 
103
+ @pytest.hookimpl(tryfirst=True)
104
+ def pytest_pycollect_makemodule(module_path: Path, parent: pytest.Collector):
105
+ """Collect a case file named on the command line as a case file, not a module.
106
+
107
+ pytest collects any `.py` path it is given explicitly as a test module whatever
108
+ its name, which would import the case file and run every assertion at import.
109
+ Answering this hook first hands the file to the case file collector instead.
110
+ """
111
+ if not _is_case_file(module_path, parent.config):
112
+ return None
113
+ return CaseFileCollector.from_parent(parent, path=module_path)
114
+
115
+
96
116
  def _diagnostics(config: pytest.Config, checker_name: str) -> dict[Path, list[Diagnostic]]:
97
117
  """Run one checker once per session and cache its result on the config."""
98
118
  cache = getattr(config, _DIAGNOSTICS, None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: type-assert
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: pytest plugin that checks a value static type and its runtime type in one assertion
5
5
  Author: user27182
6
6
  License-Expression: MIT
@@ -1,7 +1,7 @@
1
1
  {
2
- "tag": "0.2.0",
2
+ "tag": "0.2.1",
3
3
  "distance": 0,
4
- "node": "gd0866227dda697e3746b9f598708149b1e630bc0",
4
+ "node": "gc60ea7172b9c8d562dea6b21e1eb77e63352434f",
5
5
  "dirty": false,
6
6
  "branch": "HEAD",
7
7
  "node_date": "2026-09-05"
File without changes
File without changes
File without changes
File without changes
File without changes