Skip to content

Commit f78ef36

Browse files
committed
mention tests folder naming scheme in runtests.py and HACKING.md
All unit tests are now contained in subfolders named `tests` (plural). Only `unpythonic.test.fixtures` lives in a `test` (singular) subfolder, because that `test` is part of the framework name. This neatly separates the framework code from the actual unit tests.
1 parent 699497a commit f78ef36

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

HACKING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@
7474

7575
In short: regular code is in `unpythonic`, macros are in `unpythonic.syntax`, and REPL server related stuff is in `unpythonic.net`.
7676

77-
Automated tests are in `test`, under the directory whose modules they test. The test runner is, unsurprisingly, `runtests.py`, at the top level. Yes, I know many developers [prefer to separate](https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure) the `src` and `test` hierarchies at the top level; we currently don't, mostly for historical reasons.
77+
Automated tests are in `tests` (note plural), under the directory whose modules they test. The test runner is, unsurprisingly, `runtests.py`, at the top level. Yes, I know many developers [prefer to separate](https://blog.ionelmc.ro/2014/05/25/python-packaging/#the-structure) the `src` and `tests` hierarchies at the top level; we currently don't, mostly for historical reasons.
7878

7979
For coverage analysis, [`coverage.py`](https://github.com/nedbat/coveragepy) works fine for analyzing [statement coverage](https://en.wikipedia.org/wiki/Code_coverage#Basic_coverage_criteria). Block macros do cause [some false negatives](https://github.com/nedbat/coveragepy/issues/1004), but this is minor.
8080

81-
We use a custom testing framework, which lives in the modules `unpythonic.test.fixtures` and `unpythonic.syntax.testingtools`. It uses conditions and restarts to communicate between individual tests and the testset, which acts as a reporter.
81+
We use a custom testing framework, which lives in the modules `unpythonic.test.fixtures` (note singular `test`, part of the framework name) and `unpythonic.syntax.testingtools`. It uses conditions and restarts to communicate between individual tests and the testset, which acts as a reporter.
8282

8383
In retrospect, given that the main aim was compact testing syntax for macro-enabled Python code (without installing another import hook, doing which would disable the macro expander), it might have made more sense to make the testing macros compile to [pytest](https://docs.pytest.org/en/latest/). But hey, it's short, may have applications in teaching... and now we can easily write custom test runners, since the testing framework is just a `mcpyrate` library. It's essentially a *no-framework* (cf. "NoSQL"), which provides the essentials and lets the user define the rest.
8484

runtests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ def modname(path, filename): # some/dir/mod.py --> some.dir.mod
3131

3232
def main():
3333
with session():
34+
# All folders containing unit tests are named `tests` (plural).
35+
#
36+
# The testing framework is called `unpythonic.test.fixtures`,
37+
# so it lives in the only subfolder in the project that is named
38+
# `test` (singular).
3439
testsets = (("regular code", (listtestmodules(os.path.join("unpythonic", "tests")) +
3540
listtestmodules(os.path.join("unpythonic", "net", "tests")))),
36-
# This one is called "tests" to prevent a name shadowing issue;
37-
# a `test` submodule would shadow the `test` macro.
3841
("macros", listtestmodules(os.path.join("unpythonic", "syntax", "tests"))))
3942
for tsname, modnames in testsets:
4043
with testset(tsname):

unpythonic/syntax/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@
8787
# However, 0.15.0 is the initial version that runs on `mcpyrate`, and the focus is to just get this running.
8888
# Cleanups can be done in a future release.
8989

90-
# TODO: Comment in `runtests.py` and in `HACKING.md`: `test` folders renamed to `tests`; only `fixtures.py` lives in `unpythonic.test`, because the name of the framework is `unpythonic.test.fixtures`. This separates the test framework code from the unit tests.
91-
9290
# TODO: Rename `HACKING.md` to `CONTRIBUTING.md` (modern standard name).
9391

9492
# TODO: Update all tree-walking macros that handle Call nodes to ignore the node (and not recurse!) if it matches `mcpyrate.quotes.is_captured_value`

0 commit comments

Comments
 (0)