From 9366bb0996cd7c8d3f77ee45f84ddd77f7ded8b7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 6 Sep 2015 22:30:23 -0400 Subject: Add tests capturing expected behavior, including failure to match expectation indicated in docstring. --- setuptools/tests/test_setuptools.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 setuptools/tests/test_setuptools.py (limited to 'setuptools') diff --git a/setuptools/tests/test_setuptools.py b/setuptools/tests/test_setuptools.py new file mode 100644 index 00000000..f6bec644 --- /dev/null +++ b/setuptools/tests/test_setuptools.py @@ -0,0 +1,24 @@ +import pytest + +import setuptools + + +@pytest.fixture +def example_source(tmpdir): + tmpdir.mkdir('foo') + (tmpdir / 'foo/bar.py').write('') + (tmpdir / 'readme.txt').write('') + return tmpdir + + +def test_findall(example_source): + found = list(setuptools.findall(str(example_source))) + expected = ['readme.txt', 'foo/bar.py'] + assert found == expected + + +def test_findall_curdir(example_source): + with example_source.as_cwd(): + found = list(setuptools.findall()) + expected = ['readme.txt', 'foo/bar.py'] + assert found == expected -- cgit v1.2.1 From 3c0d3a91f64a9174f6e3473bbcea3be42045004a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 6 Sep 2015 22:35:48 -0400 Subject: Update docstring and test to match long-standing expectation in behavior. --- setuptools/__init__.py | 5 +++-- setuptools/tests/test_setuptools.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 2c492446..63ee15ed 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -137,8 +137,9 @@ class Command(_Command): distutils.core.Command = Command # we can't patch distutils.cmd, alas def findall(dir = os.curdir): - """Find all files under 'dir' and return the list of full filenames - (relative to 'dir'). + """ + Find all files under 'dir' and return the list of full filenames. + Unless dir is '.', return full filenames with dir prepended. """ all_files = [] for base, dirs, files in os.walk(dir, followlinks=True): diff --git a/setuptools/tests/test_setuptools.py b/setuptools/tests/test_setuptools.py index f6bec644..e1a06c96 100644 --- a/setuptools/tests/test_setuptools.py +++ b/setuptools/tests/test_setuptools.py @@ -14,6 +14,7 @@ def example_source(tmpdir): def test_findall(example_source): found = list(setuptools.findall(str(example_source))) expected = ['readme.txt', 'foo/bar.py'] + expected = [example_source.join(fn) for fn in expected] assert found == expected -- cgit v1.2.1