diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2017-01-14 19:33:55 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2017-01-14 19:33:55 -0500 |
commit | 55c48a3e041183e867a46fca51cbd6b1a5140223 (patch) | |
tree | 872758e491843c7bf611f56915333a9c71cc812c /tests/test_python.py | |
parent | fa0cbe2c60a324bc37cf897a60f2dae49bf48a87 (diff) | |
download | python-coveragepy-git-55c48a3e041183e867a46fca51cbd6b1a5140223.tar.gz |
Clean up for pull request #122
Diffstat (limited to 'tests/test_python.py')
-rw-r--r-- | tests/test_python.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/tests/test_python.py b/tests/test_python.py index c4e333ef..9027aa6c 100644 --- a/tests/test_python.py +++ b/tests/test_python.py @@ -5,8 +5,10 @@ import os import sys -from coverage import env +import pytest + +from coverage import env from coverage.python import get_zip_bytes, source_for_file from tests.coveragetest import CoverageTest @@ -30,26 +32,30 @@ class GetZipBytesTest(CoverageTest): # Run the code to see that we really got it encoded properly. __import__("encoded_"+encoding) + def test_source_for_file(tmpdir): path = tmpdir.join("a.py") src = str(path) - assert src == source_for_file(src) - assert src == source_for_file(src + 'c') - assert src == source_for_file(src + 'o') + assert source_for_file(src) == src + assert source_for_file(src + 'c') == src + assert source_for_file(src + 'o') == src unknown = src + 'FOO' - assert unknown == source_for_file(unknown) - # + assert source_for_file(unknown) == unknown + + +@pytest.mark.skipif(not env.WINDOWS, reason="not windows") +def test_source_for_file_windows(tmpdir): + path = tmpdir.join("a.py") + src = str(path) + # On windows if a pyw exists, it is an acceptable source - # - windows = env.WINDOWS - env.WINDOWS = True path_windows = tmpdir.ensure("a.pyw") assert str(path_windows) == source_for_file(src + 'c') - # + # If both pyw and py exist, py is preferred - # path.ensure(file=True) - assert src == source_for_file(src + 'c') - env.WINDOWS = windows - jython_src = "a" - assert jython_src + ".py" == source_for_file(jython_src + "$py.class") + assert source_for_file(src + 'c') == src + + +def test_source_for_file_jython(): + assert source_for_file("a$py.class") == "a.py" |