diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2013-02-02 11:15:11 -0500 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-02-02 11:15:11 -0500 |
| commit | d5f8295256d04ba8cb5b42a16ce741a34c9bb3c5 (patch) | |
| tree | ff8c6d6310bb3865411d40198c07f26eb5709959 /tests/try_execfile.py | |
| parent | b5a466fc3d7a71fc811b2430f04e6fc270858935 (diff) | |
| download | python-coveragepy-d5f8295256d04ba8cb5b42a16ce741a34c9bb3c5.tar.gz | |
Move the test directory to tests to avoid conflicts with the stdlib test package.
Diffstat (limited to 'tests/try_execfile.py')
| -rw-r--r-- | tests/try_execfile.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/try_execfile.py b/tests/try_execfile.py new file mode 100644 index 0000000..9bbabd1 --- /dev/null +++ b/tests/try_execfile.py @@ -0,0 +1,34 @@ +"""Test file for run_python_file.""" + +import os, pprint, sys + +DATA = "xyzzy" + +import __main__ + +def my_function(a): + """A function to force execution of module-level values.""" + return "my_fn(%r)" % a + +FN_VAL = my_function("fooey") + +try: + pkg = __package__ +except NameError: + pkg = "*No __package__*" + +globals_to_check = { + '__name__': __name__, + '__file__': __file__, + '__doc__': __doc__, + '__builtins__.has_open': hasattr(__builtins__, 'open'), + '__builtins__.dir': dir(__builtins__), + '__package__': pkg, + 'DATA': DATA, + 'FN_VAL': FN_VAL, + '__main__.DATA': getattr(__main__, "DATA", "nothing"), + 'argv': sys.argv, + 'path': [os.path.normcase(p) for p in sys.path], +} + +pprint.pprint(globals_to_check) |
