summaryrefslogtreecommitdiff
path: root/tests/support.py
diff options
context:
space:
mode:
authorBenjamin Peterson <devnull@localhost>2008-09-21 19:25:33 -0500
committerBenjamin Peterson <devnull@localhost>2008-09-21 19:25:33 -0500
commitd97401fd65164c0d472966d8c20f29d27c4a6055 (patch)
tree037706aba7001e959421041569e7b5f1c79fe07c /tests/support.py
parent88f8ee809d47a92ec975a32570aab2313eb1b487 (diff)
downloadpygments-d97401fd65164c0d472966d8c20f29d27c4a6055.tar.gz
instead of picking a random modules to test, provide an easy way to get the current one
Diffstat (limited to 'tests/support.py')
-rw-r--r--tests/support.py20
1 files changed, 5 insertions, 15 deletions
diff --git a/tests/support.py b/tests/support.py
index f2df4747..67cf69d7 100644
--- a/tests/support.py
+++ b/tests/support.py
@@ -4,22 +4,12 @@ Support for Pygments tests
"""
import os
-import random
-def _get_all_test_files():
- tests = []
- here = os.path.abspath(os.path.dirname(__file__))
- for dirpath, dirs, files in os.walk(here):
- tests.extend(os.path.join(dirpath, fn) for fn in files
- if fn.startswith("test_") and fn.endswith(".py"))
- dirs[:] = [d for d in dirs if d.startswith("test_")]
- return tests
-
-_testfiles = _get_all_test_files()
-
-def test_file():
+def location(mod_name):
"""
- Randomly choose a file to test.
+ Return the file and directory that the code for *mod_name* is in.
"""
- return random.choice(_testfiles)
+ source = mod_name[:-1] if mod_name.endswith("pyc") else mod_name
+ source = os.path.abspath(source)
+ return source, os.path.dirname(source)