diff options
author | Benjamin Peterson <devnull@localhost> | 2008-09-18 21:03:16 -0500 |
---|---|---|
committer | Benjamin Peterson <devnull@localhost> | 2008-09-18 21:03:16 -0500 |
commit | ae5c5fdb18fa618e84c408264f596ebdec96e5df (patch) | |
tree | a4feb5b6a971d2b72b4827bd7a33d33aa46fa9bd /tests/support.py | |
parent | e6600347dac8dddc630cac6e55c08dea84b20f00 (diff) | |
download | pygments-ae5c5fdb18fa618e84c408264f596ebdec96e5df.tar.gz |
remove __builtin__.testdir/testfile magic
This adds a new file tests/support.py
Diffstat (limited to 'tests/support.py')
-rw-r--r-- | tests/support.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/support.py b/tests/support.py new file mode 100644 index 00000000..f2df4747 --- /dev/null +++ b/tests/support.py @@ -0,0 +1,25 @@ +# coding: utf-8 +""" +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(): + """ + Randomly choose a file to test. + """ + return random.choice(_testfiles) |