Skip to content

Commit

Permalink
test functions in the order that they were declared
Browse files Browse the repository at this point in the history
  • Loading branch information
rudymatela committed Aug 26, 2024
1 parent 94c9f3d commit b04d861
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
TODO for leancheck.py
=====================

* test functions in the order that they were declared

* add documentation to all functions

* simplify code
Expand Down
7 changes: 6 additions & 1 deletion src/leancheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,12 @@ def holds(prop, max_tests=360):
def testmod(max_tests=360, silent=False, verbose=False):
n_failures = 0
n_properties = 0
for name, member in getmembers(sys.modules["__main__"]):
def lineno(m):
try:
return m[1].__code__.co_firstlineno
except AttributeError:
return -1
for name, member in sorted(getmembers(sys.modules["__main__"]), key=lineno):
if name.startswith("prop_") and callable(member):
n_properties += 1
passed = check(member, max_tests=max_tests, silent=silent, verbose=verbose)
Expand Down

0 comments on commit b04d861

Please sign in to comment.