Skip to content

Commit

Permalink
ensure django is prioritized over other python methods
Browse files Browse the repository at this point in the history
  • Loading branch information
xavdid committed Jun 28, 2023
1 parent 6922eba commit 223d709
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This project uses [SemVer](https://semver.org/) for versioning. Its public APIs,

_released `TBD`_

- add django support (https://github.com/xavdid/universal-test-runner/pull/1)
- add django support (https://github.com/xavdid/universal-test-runner/pull/1) and ensure it takes precedence over more generic python testing methods (https://github.com/xavdid/universal-test-runner/pull/3)
- print the command being run; disable by setting `UTR_DISABLE_ECHO` in the environment (https://github.com/xavdid/universal-test-runner/pull/2)

## 0.3.0
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ The package also ships a command to surface info about itself: `universal-test-r

## Supported Languages

This tree describes the rough priority order within each language (not the languages themselves).

1. Python
- uses `pytest` if you've run `pytest` before. You'll need to run pytest manually on clean installs before `t` will work
- checks for `manage.py` (Django)
- else uses `pytest` if you've run `pytest` before. You'll need to run pytest manually on clean installs before `t` will work
- looks for a `tests.py` file if not
2. Rust
- `cargo test`
Expand Down
4 changes: 4 additions & 0 deletions tests/test_matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def __repr__(self) -> str:
"test_case",
[
CommandFinderTestCase([".pytest_cache"], "pytest"),
CommandFinderTestCase(["manage.py"], "./manage.py test"),
CommandFinderTestCase(["manage.py", ".pytest_cache"], "./manage.py test"),
CommandFinderTestCase(["tests.py"], "python tests.py"),
CommandFinderTestCase(["go.mod"], "go test ./..."),
CommandFinderTestCase(
Expand All @@ -164,6 +166,8 @@ def test_find_test_command(
"""
while other tests verify that a specific file passes a specific matcher,
this makes assertions about the resulting command while running through the entire matching process
it's useful for ensuring ordering of certain matchers
"""
c = build_context(test_case.files, test_case.args)
assert matchers.find_test_command(c) == test_case.expected_command.split()
Expand Down
5 changes: 3 additions & 2 deletions universal_test_runner/matchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ def js_builder(name: str, lockfile: str) -> "Matcher":

# these are checked in order
ALL_MATCHERS: list[Matcher] = [
pytest,
# make sure django goes before pytest, since django can use pytest
django,
pytest,
py,
# ensure ordering here
# ensure ordering for go matchers
go_multi,
go_single,
elixir,
Expand Down

0 comments on commit 223d709

Please sign in to comment.